1
我爲我的2種數據類型Act和Scene構建了2個工廠。除了我的場景的更新功能(創建,讀取,刪除工作正常),一切都可以完美運行。對於我的生活,我不能找出幕後更新功能無法正常工作,我剛剛得到這個消息:角度資源更新不起作用
TypeError: Object function Resource(value){
copy(value || {}, this);
} has no method 'update'
at Object.ScenesUpdateCtrl.$scope.save
我有2個工廠:
app.factory('ActsService', function($resource) {
return $resource('/api/acts/:id', {id: '@id'}, {update: {method: 'PUT'}});
});
app.factory('ScenesService', function($resource) {
$resource('/api/scenes/:id', {id: '@id'}, {update: {method: 'PUT'}});
$resource('/api/scenes/:actId', {actId: '@id'}, {query: {method: 'GET', isArray: true}});
$resource('/api/scenes/:actId/:id', {actId: '@actId', id: '@id'}, {get: {method: 'GET'}});
return $resource('/api/scenes/:actId/:id', {actId: '@actId', id: '@id'}, {delete: {method: 'DELETE'}});
});
而且有些控制器處理所有更新操作。
function ActsUpdateCtrl ($scope, $location, $routeParams, ActsService) {
var id = $routeParams.id
$scope.act = ActsService.get({id: id})
$scope.action = "Update"
$scope.save = function() {
ActsService.update({id: id}, $scope.act, function() {
$location.path('/admin/acts')
})
}
}
function ScenesUpdateCtrl ($scope, $location, $routeParams, ScenesService) {
var id = $routeParams.id
var actId = $routeParams.actId
ScenesService.get({actId: actId, id: id}, function(resp){
$scope.scene = resp
$scope.actId = resp.PartitionKey
$scope.prev = resp.prev.split(",")
})
$scope.scenes = ScenesService.query({actId: actId})
$scope.action = "Update"
$scope.save = function() {
$scope.scene.prev = $scope.prev
ScenesService.update({id: id}, $scope.scene, function() {
$location.path('/admin/acts/' + $scope.actId)
})
}
}
Act works,Scene會引發前面提到的錯誤信息。
更容易調試這些東西在一個笨蛋。 –