我做这个Customer
服务与$resource
:ngResource:自定义更新的方法清除实例
.factory('Customer', function($resource, apiURL){
return $resource(apiURL+'customers/:id', { id: '@id' }, {
'update': {method: 'PUT'}
})
})
当我更新customer
(即Customer
服务的实例),以及承诺后是解决了,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 }
})
});