久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <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="qwawimqqmiuu" 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)將數

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

          <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="qwawimqqmiuu" id='InCiz'><tfoot id='InCiz'></tfoot><dl id='InCiz'><fieldset id='InCiz'></fieldset></dl></div>

                  <tfoot id='InCiz'></tfoot>
                  本文介紹了如何使用 MEAN 堆棧(MySQL、Express、Angular、Node)將數據插入數據庫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  如何使用 MEAN 堆棧(MySQL、Express、Angular、Node)將數據插入數據庫?我在插入時遇到了問題.請幫我解決這個問題.這是我的代碼.我是 MEAN 的新手.

                  index.html

                  <頭><link rel="stylesheet" ><標題>注冊頁面</title><身體><div class="container" ng-app="bookitnow" ng-controller="myCtrl"><h1>注冊</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({主機:'本地主機',用戶:'根',密碼 : '',數據庫:'bookitnow'});connection.connect(function(err) {如果(!錯誤)console.log('數據庫已連接');別的console.log('數據庫連接錯誤.');});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('收到請求:', 數據);connection.query('INSERT INTO register SET ?', data, function(err,res){如果(錯誤)拋出錯誤;console.log('記錄插入');});app.listen(5500);console.log('你好,來自 server.js');

                  controller.js

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

                  解決方案

                  在您的 controller.js 中,嘗試以下操作,看看會發生什么.

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

                  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)
                              });
                       };
                  });
                  

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

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

                  相關文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                  How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統)中使用 MySQL?)
                  PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任務計劃程序中的 PowerShell MySQL 備份腳本錯誤 0x00041301)
                  Import the data from the XML files into a MySQL database(將數據從 XML 文件導入 MySQL 數據庫)
                  installed Xampp on Windows 7 32-bit. Errors when starting(在 Windows 7 32 位上安裝 Xampp.啟動時的錯誤)
                  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="qwawimqqmiuu" id='JcSkP'><tfoot id='JcSkP'></tfoot><dl id='JcSkP'><fieldset id='JcSkP'></fieldset></dl></div>

                      主站蜘蛛池模板: 国产三区av| 欧美一区二区三区精品免费 | 成人国产精品久久 | 男女免费网站 | 99精品亚洲国产精品久久不卡 | 欧美性一区二区三区 | 日韩福利在线 | 人人干人人干人人干 | 国产成人自拍一区 | 在线黄色网 | 欧美一区二区三区在线观看视频 | 欧美激情综合 | 国产小视频在线 | 人人种亚洲 | 午夜激情网 | 亚洲三区在线观看 | 精品久久久久久久 | 亚洲天堂久久 | 亚洲一本 | 91久色| 国产日韩精品一区二区三区 | 色综合天天天天做夜夜夜夜做 | 亚洲精品二区 | 日韩欧美专区 | 久久免费资源 | 亚洲精品国产成人 | 久久最新| h视频在线观看免费 | 在线视频91| 国产精品国产成人国产三级 | 中文字幕 亚洲一区 | 激情久久av一区av二区av三区 | 久久一区二区三区电影 | 日韩欧美在 | 天天搞夜夜操 | 精品一区二区观看 | 国产一区二区自拍 | 中文字幕一区二区三区在线观看 | 国产精品久久久久久52avav | 久久久久久91香蕉国产 | 欧美国产中文 |