-1
這是我controller.js的NodeJS:數據類型返回undefined
$scope.saveDetails = function(){
if($scope.editMode == false){
//$scope.hidesave = false;
//$scope.person = "";
console.log("i am in save")
console.log($scope.person);
$http.post('/details',$scope.person).success(function(response){
console.log(response);
refresh();
})
$state.go("itemList");
這是我Route.JS
module.exports = function (app){
console.log("Inside Routes");
app.get('/details', require('./details/details').getDetails);
app.get('/details/:id', require('./details/details').getDetails_id);
app.post('/details', require('./details/details').saveDetails);
app.delete('/details/:id',require('./details/details').deleteDetails);
app.post('/details/:id',require('./details/details').updateDetails);
};
這是我details.js wher實際執行情況是:
exports.saveDetails = function (req, res) {
console.log("Hi");
console.log("this is to save: ",req.body);
var person = new req.app.schema.detailsdb(req.body);
person.save(req.body,function(err,docs){
res.json(docs);
console.log("docs: ",docs)
});
};
這裏req.body返回未定義當我嘗試從HTML頁插入數據到數據庫,我寫了使用貓鼬的數據庫
你擁有包括快遞體解析器中間件? – oznu