我有這樣的形式和數據不出現不傳遞給我的後端:
<div ng-controller="searchController">
<form ng-submit="submit()">
<input type="text" name="name" ng-model="namegirl" />
<input type="text" name="namewod" ng-model="namewod" />
<input type="submit"/>
</form>
現在在我的script.js控制器是這樣的:
myApp.controller('searchController', ['$scope', '$filter', '$http', function ($scope, $filter, $http) {
let data = {
namegirl :$scope.namegirl,
name :$scope.namewod
};
console.log(data);
$http.post('/wodsearch',data)
.success(function (response) {
console.log(response.data);
})
.error(function (response, status) {
console.log(response);
});
}]);
現在我的魔杖從我的形式在我的服務器傳遞的NodeJS我的數據我有這樣的代碼:
app.post('/wodsearch',function(req, res ,next){
// how to get here the data from my angular
});
的可能的複製[如何消耗的Express應用程序的JSON POST數據(https://stackoverflow.com/questions/10005939/how-do-i-consume-the- json-post-data-in-express-application) –