Angularjs 如何在服务器nodejs响应中查看角度表单字段?
我是新手。在这里,我尝试使用节点服务器发布角度表单Angularjs 如何在服务器nodejs响应中查看角度表单字段?,angularjs,node.js,Angularjs,Node.js,我是新手。在这里,我尝试使用节点服务器发布角度表单 Here is my code in register.js $scope.sendForm = function() { alert("form is good"); $scope.fileds= $scope.data; var posting = $http({ method: 'POST',
Here is my code
in register.js
$scope.sendForm = function() {
alert("form is good");
$scope.fileds= $scope.data;
var posting = $http({
method: 'POST',
/*posting to /post */
url: '/post',
data: $scope.data,
processData: false
})
posting.success(function (response) {
/*executed when server responds back*/
console.log(response);
$scope.response.data = response;
});
};
而且
app.js server side
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser());
app.post('/post', function (req, res) {
console.log(req.body);
res.setHeader('Content-Type', 'application/json');
req.body.serverMessage = "This is response from server"
res.end(JSON.stringify(req.body));
});
我可以看到response.data,因为这是来自表单上服务器的响应。
但我如何能得到文件和他们的价值观张贴从表单上提交的角度形式
有人能告诉我吗?使用
节点检查器
启动节点检查器node--debug app.js
在调试模式下启动节点应用程序(我建议在检测到更改时使用以重新启动进程) app.post('/post', function (req, res) {
debugger;
res.setHeader('Content-Type', 'application/json');
req.body.serverMessage = "This is response from server"
res.end(JSON.stringify(req.body));
});
一旦到达该端点,您就可以检查请求并使用javascript控制台。如果您熟悉Chrome开发工具,那么您会非常熟悉它