Я хочу, чтобы обновить свой объект JSON с помощью метода PUT с помощью функции обновления в angularjs, но после использования метода обновления я получаю ошибку:Проблемы, связанные с методом обновления в 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