I make this Customer
service with $resource
:
.factory('Customer', function($resource, apiURL){
return $resource(apiURL+'customers/:id', { id: '@id' }, {
'update': {method: 'PUT'}
})
})
When I update the customer
(that is a Instance of Customer
service), and after the promise is resolved, the customer
var is cleaned. Why?
$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 }
})
});