pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <bdo id='823tK'></bdo><ul id='823tK'></ul>
    <tfoot id='823tK'></tfoot>

      <i id='823tK'><tr id='823tK'><dt id='823tK'><q id='823tK'><span id='823tK'><b id='823tK'><form id='823tK'><ins id='823tK'></ins><ul id='823tK'></ul><sub id='823tK'></sub></form><legend id='823tK'></legend><bdo id='823tK'><pre id='823tK'><center id='823tK'></center></pre></bdo></b><th id='823tK'></th></span></q></dt></tr></i><div class="eusqmyq" id='823tK'><tfoot id='823tK'></tfoot><dl id='823tK'><fieldset id='823tK'></fieldset></dl></div>

      <small id='823tK'></small><noframes id='823tK'>

    1. <legend id='823tK'><style id='823tK'><dir id='823tK'><q id='823tK'></q></dir></style></legend>

      1. 如何使用 MEAN 堆棧(MySQL、Express、Angular、Node)將數(shù)

        how to insert data into database using MEAN stack (MySQL, Express, Angular, Node)(如何使用 MEAN 堆棧(MySQL、Express、Angular、Node)將數(shù)據(jù)插入數(shù)據(jù)庫(kù))

          <bdo id='InCiz'></bdo><ul id='InCiz'></ul>

            <small id='InCiz'></small><noframes id='InCiz'>

                <legend id='InCiz'><style id='InCiz'><dir id='InCiz'><q id='InCiz'></q></dir></style></legend>
                  <tbody id='InCiz'></tbody>

                1. <i id='InCiz'><tr id='InCiz'><dt id='InCiz'><q id='InCiz'><span id='InCiz'><b id='InCiz'><form id='InCiz'><ins id='InCiz'></ins><ul id='InCiz'></ul><sub id='InCiz'></sub></form><legend id='InCiz'></legend><bdo id='InCiz'><pre id='InCiz'><center id='InCiz'></center></pre></bdo></b><th id='InCiz'></th></span></q></dt></tr></i><div class="8yc2e2a" id='InCiz'><tfoot id='InCiz'></tfoot><dl id='InCiz'><fieldset id='InCiz'></fieldset></dl></div>

                  <tfoot id='InCiz'></tfoot>
                  本文介紹了如何使用 MEAN 堆棧(MySQL、Express、Angular、Node)將數(shù)據(jù)插入數(shù)據(jù)庫(kù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  如何使用 MEAN 堆棧(MySQL、Express、Angular、Node)將數(shù)據(jù)插入數(shù)據(jù)庫(kù)?我在插入時(shí)遇到了問(wèn)題.請(qǐng)幫我解決這個(gè)問(wèn)題.這是我的代碼.我是 MEAN 的新手.

                  index.html

                  <頭><link rel="stylesheet" ><標(biāo)題>注冊(cè)頁(yè)面</title><身體><div class="container" ng-app="bookitnow" ng-controller="myCtrl"><h1>注冊(cè)</h1><form method="post"><div class="form-group"><input type="text" class="form-control" id="firstName" ng-model="fname" placeholder="First Name" required>

                  <div class="form-group"><input type="text" class="form-control" id="lastName" ng-model="lname" placeholder="Last Name" required>

                  <div class="form-group"><input type="email" class="form-control" id="email" ng-model="email" placeholder="Email Address" required>

                  <div class="form-group"><input type="text" class="form-control" id="phone" ng-model="phone" placeholder="Phone" required>

                  <button type="submit" class="btn btn-info" ng-click="submit()">提交</button></表單>

                  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script><script src="controllers/controller.js"></script></html>

                  server.js

                  var express = require("express");var app = express();var bodyParser = require('body-parser');var mysql = require('mysql');var connection = mysql.createConnection({主機(jī):'本地主機(jī)',用戶:'根',密碼 : '',數(shù)據(jù)庫(kù):'bookitnow'});connection.connect(function(err) {如果(!錯(cuò)誤)console.log('數(shù)據(jù)庫(kù)已連接');別的console.log('數(shù)據(jù)庫(kù)連接錯(cuò)誤.');});app.use(express.static(__dirname + '/public'));app.get('/index.html', function(req, res){res.sendFile(__dirname + '/public' + 'index.html');});app.post('/index.html', function(req, res, next) {var data = req.body;console.log('收到請(qǐng)求:', 數(shù)據(jù));connection.query('INSERT INTO register SET ?', data, function(err,res){如果(錯(cuò)誤)拋出錯(cuò)誤;console.log('記錄插入');});app.listen(5500);console.log('你好,來(lái)自 server.js');

                  controller.js

                  var app = angular.module('bookitnow',[]);app.controller('myCtrl', function($scope,$http){$scope.submit = function() {變量數(shù)據(jù) = {fName : $scope.fname,lName : $scope.lname,電子郵件:$scope.email,電話:$scope.phone}};$http.post('/index.html', &scope.data).success(功能(數(shù)據(jù),狀態(tài),標(biāo)題,配置){$scope.result = 數(shù)據(jù);console.log("插入成功")}).錯(cuò)誤(功能(數(shù)據(jù),狀態(tài),標(biāo)題,配置){$scope.result = "數(shù)據(jù):" + 狀態(tài);});

                  解決方案

                  在您的 controller.js 中,嘗試以下操作,看看會(huì)發(fā)生什么.

                  var app = angular.module('bookitnow',[]);app.controller('myCtrl', function($scope, $http){$scope.submit = function() {變量數(shù)據(jù) = {fName : $scope.fname,lName : $scope.lname,電子郵件:$scope.email,電話:$scope.phone};$http.post('/index.html', 數(shù)據(jù)).then(功能(響應(yīng)){控制臺(tái)日志(響應(yīng))},功能(響應(yīng)){控制臺(tái)日志(響應(yīng))});};});

                  How to insert data into database using MEAN stack (MySQL, Express, Angular, Node)? I am facing the problem at the time of insertion. Please help me to solve this. Here is my code. I'm newbie in MEAN.

                  index.html

                  <html ng-app="bookitnow">
                  <head>
                      <link rel="stylesheet" >
                  
                      <title> Registration Page </title>
                  </head>
                  <body>
                  <div class="container" ng-app="bookitnow" ng-controller="myCtrl">
                    <h1>Register</h1>
                      <form method="post">
                      <div class="form-group">
                          <input type="text" class="form-control" id="firstName" ng-model="fname" placeholder="First Name" required>
                      </div>
                      <div class="form-group">
                          <input type="text" class="form-control" id="lastName" ng-model="lname" placeholder="Last Name" required>
                      </div>
                      <div class="form-group">
                          <input type="email" class="form-control" id="email" ng-model="email" placeholder="Email Address" required>
                      </div>
                      <div class="form-group">
                          <input type="text" class="form-control" id="phone" ng-model="phone" placeholder="Phone" required>
                      </div>
                  
                  <button type="submit" class="btn btn-info" ng-click="submit()">Submit</button>
                  
                  </form>
                  </div>
                  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
                  <script src="controllers/controller.js"></script>
                  
                  </body>
                  </html>
                  

                  server.js

                  var express    = require("express");
                  var app = express();
                  var bodyParser = require('body-parser');
                  var mysql      = require('mysql');
                  var connection = mysql.createConnection({
                     host     : 'localhost',
                     user     : 'root',
                     password : '',
                     database : 'bookitnow'
                  });
                  
                  connection.connect(function(err) {
                     if (!err)
                       console.log('Database is connected');
                     else
                       console.log('DB connection error.');
                  });
                  
                  app.use(express.static(__dirname + '/public'));
                  
                  app.get('/index.html', function(req, res){
                      res.sendFile(__dirname + '/public' + 'index.html');
                  });
                  
                  
                  app.post('/index.html', function(req, res, next) {
                    var data = req.body;
                      console.log('request received:', data);
                  
                      connection.query('INSERT INTO register SET ?', data, function(err,res){
                        if(err) throw err;
                          console.log('record inserted');
                      });  
                  
                  app.listen(5500);
                  
                  console.log('Hi from server.js');
                  

                  controller.js

                  var app = angular.module('bookitnow',[]);
                          app.controller('myCtrl', function($scope,$http){
                          $scope.submit = function() {
                  
                              var data = {
                                      fName   : $scope.fname, 
                                      lName   : $scope.lname,
                                      email   : $scope.email,
                                      phone   : $scope.phone
                                  }   
                              };
                  
                              $http.post('/index.html', &scope.data)
                              .success(function (data, status, headers, config) {
                                      $scope.result = data;
                                      console.log("inserted successfully")
                                  })
                                  .error(function(data, status, header, config){
                                      $scope.result = "Data: " + status;
                  
                  
                                  });
                  

                  解決方案

                  In your controller.js, try the following and see what happens.

                  var app = angular.module('bookitnow',[]);
                  app.controller('myCtrl', function($scope, $http){
                      $scope.submit = function() {
                  
                          var data = {
                              fName   : $scope.fname, 
                              lName   : $scope.lname,
                              email   : $scope.email,
                              phone   : $scope.phone
                          }; 
                  
                          $http
                              .post('/index.html', data)
                              .then(function (response) {
                                  console.log(response)
                              }, function(response){
                                  console.log(response)
                              });
                       };
                  });
                  

                  這篇關(guān)于如何使用 MEAN 堆棧(MySQL、Express、Angular、Node)將數(shù)據(jù)插入數(shù)據(jù)庫(kù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產(chǎn)品、類別和元數(shù)據(jù)的 SQL 查詢 woocommerce/wordpress)
                  How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統(tǒng))中使用 MySQL?)
                  PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任務(wù)計(jì)劃程序中的 PowerShell MySQL 備份腳本錯(cuò)誤 0x00041301)
                  Import the data from the XML files into a MySQL database(將數(shù)據(jù)從 XML 文件導(dǎo)入 MySQL 數(shù)據(jù)庫(kù))
                  installed Xampp on Windows 7 32-bit. Errors when starting(在 Windows 7 32 位上安裝 Xampp.啟動(dòng)時(shí)的錯(cuò)誤)
                  Mysql lower case table on Windows xampp(Windows xampp 上的 Mysql 小寫表)
                  1. <legend id='JcSkP'><style id='JcSkP'><dir id='JcSkP'><q id='JcSkP'></q></dir></style></legend>

                    <small id='JcSkP'></small><noframes id='JcSkP'>

                    <tfoot id='JcSkP'></tfoot>

                      <bdo id='JcSkP'></bdo><ul id='JcSkP'></ul>

                    1. <i id='JcSkP'><tr id='JcSkP'><dt id='JcSkP'><q id='JcSkP'><span id='JcSkP'><b id='JcSkP'><form id='JcSkP'><ins id='JcSkP'></ins><ul id='JcSkP'></ul><sub id='JcSkP'></sub></form><legend id='JcSkP'></legend><bdo id='JcSkP'><pre id='JcSkP'><center id='JcSkP'></center></pre></bdo></b><th id='JcSkP'></th></span></q></dt></tr></i><div class="cgwymgk" id='JcSkP'><tfoot id='JcSkP'></tfoot><dl id='JcSkP'><fieldset id='JcSkP'></fieldset></dl></div>

                      主站蜘蛛池模板: Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | 阜阳在线-阜阳综合门户| 合金ICP光谱仪(磁性材料,工业废水)-百科| 油罐车_加油机_加油卷盘_加油机卷盘_罐车人孔盖_各类球阀_海底阀等车用配件厂家-湖北华特专用设备有限公司 | 成都治疗尖锐湿疣比较好的医院-成都治疗尖锐湿疣那家医院好-成都西南皮肤病医院 | 电液推杆生产厂家|电动推杆|液压推杆-扬州唯升机械有限公司 | 江苏大隆凯科技有限公司| 众能联合-提供高空车_升降机_吊车_挖机等一站工程设备租赁 | 萃取箱-萃取槽-PVC萃取箱厂家-混合澄清槽- 杭州南方化工设备 | 扬尘在线监测系统_工地噪声扬尘检测仪_扬尘监测系统_贝塔射线扬尘监测设备「风途物联网科技」 | 广州办公室设计,办公室装修,写字楼设计,办公室装修公司_德科 | PE一体化污水处理设备_地埋式生活污水净化槽定制厂家-岩康塑业 | 强效碱性清洗剂-实验室中性清洗剂-食品级高纯氮气发生器-上海润榕科学器材有限公司 | 爱德华真空泵油/罗茨泵维修,爱发科-比其尔产品供应东莞/杭州/上海等全国各地 | 大_小鼠elisa试剂盒-植物_人Elisa试剂盒-PCR荧光定量试剂盒-上海一研生物科技有限公司 | 电镀整流器_微弧氧化电源_高频电解电源_微弧氧化设备厂家_深圳开瑞节能 | 油缸定制-液压油缸厂家-无锡大鸿液压气动成套有限公司 | 杭州用友|用友软件|用友财务软件|用友ERP系统--杭州协友软件官网 | 大通天成企业资质代办_承装修试电力设施许可证_增值电信业务经营许可证_无人机运营合格证_广播电视节目制作许可证 | 清水-铝合金-建筑模板厂家-木模板价格-铝模板生产「五棵松」品牌 | 阴离子_阳离子聚丙烯酰胺厂家_聚合氯化铝价格_水处理絮凝剂_巩义市江源净水材料有限公司 | 国资灵活用工平台_全国灵活用工平台前十名-灵活用工结算小帮手 | 注塑机-压铸机-塑料注塑机-卧式注塑机-高速注塑机-单缸注塑机厂家-广东联升精密智能装备科技有限公司 | 光泽度计_测量显微镜_苏州压力仪_苏州扭力板手维修-苏州日升精密仪器有限公司 | 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | TMT观察网_独特视角观察TMT行业 派财经_聚焦数字经济内容服务平台 | 沈阳液压泵_沈阳液压阀_沈阳液压站-沈阳海德太科液压设备有限公司 | 扬尘在线监测系统_工地噪声扬尘检测仪_扬尘监测系统_贝塔射线扬尘监测设备「风途物联网科技」 | RS系列电阻器,RK_RJ启动调整电阻器,RQ_RZ电阻器-上海永上电器有限公司 | 美的商用净水器_美的直饮机_一级代理经销商_Midea租赁价格-厂家反渗透滤芯-直饮水批发品牌售后 | 一点车讯-汽车网站,每天一点最新车讯!| 锌合金压铸-铝合金压铸厂-压铸模具-冷挤压-誉格精密压铸 | 定量包装秤,吨袋包装称,伸缩溜管,全自动包装秤,码垛机器人,无锡市邦尧机械工程有限公司 | 翰香原枣子坊加盟费多少钱-正宗枣核糕配方培训利润高飘香 | 防爆正压柜厂家_防爆配电箱_防爆控制箱_防爆空调_-盛通防爆 | 营养师网,营养师考试时间,报名入口—网站首页 | 无刷电机_直流无刷电机_行星减速机-佛山市藤尺机电设备有限公司 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | 早报网| 喷砂机厂家_自动喷砂机生产_新瑞自动化喷砂除锈设备 | 吨袋包装机|吨包秤|吨包机|集装袋包装机-烟台华恩科技 | 北京银联移动POS机办理_收银POS机_智能pos机_刷卡机_收银系统_个人POS机-谷骐科技【官网】 |