我想用在angularjs更新功能来更新我的JSON对象与PUT方法更新方法,但使用的更新方法后出现的问题,我得到的错误:在angularjs
angular.js:14324 TypeError: menuFactory.getDishes(...).update is not a function
at b.$scope.submitComment (controllers.js:104)
at fn (eval at compile (angular.js:15152), <anonymous>:4:159)
at e (angular.js:26673)
at b.$eval (angular.js:17958)
at b.$apply (angular.js:18058)
at HTMLFormElement.<anonymous> (angular.js:26678)
at bg (angular.js:3613)
at HTMLFormElement.d (angular.js:3601)
这是我service.js代码:
.service('menuFactory', ['$resource', 'baseURL', function($resource,baseURL) {
this.getDishes = function(){
return $resource("localhost:3000/"+"dishes/:id",{update:{method:'PUT' }});
};
}])
,这是我的控制器代码:
.controller('DishCommentController', ['$scope', 'menuFactory', function($scope,menuFactory) {
$scope.mycomment= {rating:"5", comment:"", author:""};
$scope.dish.comments.push($scope.mycomment);
menuFactory.getDishes().update({ id:$scope.dish.id }, $scope.dish);
}])
为什么角不RECOG nize更新方法,我有get方法相同的问题,但更新我的角度1.6.0版本后get方法解决问题。但现在我有与Update方法相同的问题。
我在做什么错在这里?
更新我的答案。 – Baconbeastnz