Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将json从Angular JS传递到Node JS_Javascript_Angularjs_Json_Node.js_Express - Fatal编程技术网

Javascript 将json从Angular JS传递到Node JS

Javascript 将json从Angular JS传递到Node JS,javascript,angularjs,json,node.js,express,Javascript,Angularjs,Json,Node.js,Express,我试图将前端(角度)和后端(节点)结合起来,但前端并没有将json传递给后端 这是我的带有Angular js的html代码 Index.html <html> <head>Testing <script src = "angular.min.js" ></script> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($

我试图将前端(角度)和后端(节点)结合起来,但前端并没有将json传递给后端

这是我的带有Angular js的html代码

Index.html

<html>
<head>Testing
<script src = "angular.min.js" ></script>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope,$http) {
   $scope.submit= function(){
      var data = $.param({
        book: JSON.stringify({
            author: $scope.author,
            title : $scope.title,
            body : $scope.body
        })
      });
    console.log(data)
      $http.post("/", data).success(function(data, status) {
        console.log('Data posted successfully');
      })
   }
});
</script>
</head>

<body ng-app="myApp">    
  <div ng-controller="myCtrl">
    <form>
      Author:
      <input type="text" ng-model="author">
      <br>
      <br> Title:
      <input type="text" ng-model="title">
      <br>
      <br> Body:
      <input type="author" ng-model="body">
      <br>
      <br>
      <input type="submit" value="Submit" ng-click="submit()">
    </form>
  </div>  
</body>
</html>
我在“/”路径的浏览器中获得Index.html,但当我提交时,什么都没有发生

提前谢谢

你能试试这个吗

var data = {
  book: {            
    author: $scope.author,
    title : $scope.title,
    body : $scope.body
  }
}

$http.post("/", data).success(function(data, status) {
    console.log('Data posted successfully');
})
你能试试这个吗

var data = {
  book: {            
    author: $scope.author,
    title : $scope.title,
    body : $scope.body
  }
}

$http.post("/", data).success(function(data, status) {
    console.log('Data posted successfully');
})

你分析过发送的数据了吗?就像使用chrome开发工具网络选项卡一样。还是一开始就没有发出请求?在检查页面时,它无法加载“angular.min.js”,但我已将其放在同一个文件夹中,我不知道为什么会发生@gilbertnwaiwu,你是说angular.min.js根本没有加载?是的。我使用了它的在线版本,这正是问题所在。我试过用“node modules/angular/angular.min.js”和“angular.min.js”将文件放在这两个位置,但都没有加载。你分析过发送的数据吗?就像使用chrome开发工具网络选项卡一样。还是一开始就没有发出请求?在检查页面时,它无法加载“angular.min.js”,但我已将其放在同一个文件夹中,我不知道为什么会发生@gilbertnwaiwu,你是说angular.min.js根本没有加载?是的。我使用了它的在线版本,这正是问题所在。我试过使用“node modules/angular/angular.min.js”和“angular.min.js”将文件放置在这两个位置,但没有加载。我面临的问题是res.status(200)。send('Ok')。它没有发送OK@sunil请帮助我重新路由它我面临的问题是res.status(200)。发送('OK')。它没有发送OK@sunil请帮我重新发送