я делаю это 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 }
})
});