【发布时间】:2016-04-22 05:03:01
【问题描述】:
我用$resource 做这个Customer 服务:
.factory('Customer', function($resource, apiURL){
return $resource(apiURL+'customers/:id', { id: '@id' }, {
'update': {method: 'PUT'}
})
})
当我更新customer(这是Customer 服务的实例),并且在promise 被解决后,customer var 被清除.为什么?
$scope.customer = Customer.get({id: $stateParams.id}, function (){
console.log($scope.customer) // Object {id: 1, name: 'John Doe', ...}
$scope.customer.$update()
.then(function () {
console.log($scope.customer) // Object { status: true, $promise: Object, $resolved: true }
})
});
【问题讨论】:
标签: angularjs ngresource