How handle resources in AngularJS 1.2 correctly?
I updated my AngularJS from 1.0.7 to 1.2rc1 yesterday to check the new
features. All works fine, but i run into some problems with ngResource.
With these factory i get dummy data of a json file:
angular.module('RESTServices', ['ngResource'])
.factory('Customer', function($resource){
return $resource(base+'customer.json', {}, {
'query' : { method: 'GET', isArray: true, cache: caching }
});
});
I inject the RESTService in a controller and use it like:
Customer.query({}, function(response){
$scope.customers = response;
});
For one thing they are a array of customers in $scope.customers, for
another thing they are to additional objects ($promise and $resolved) in
the response. Screenshot of console show the resolve object.
And if i want to iterate over the response, the iterator walk all over the
200 customers and the $promise and $resolved object and i get errors
because my code dont know how to handle these objects. In version 1.0.7
there was only 200 customers in the response.
Did i something wrong? Must i check each item while iterating if is not
$resolved or $response? Documentation is not clear about that in the
moment.
No comments:
Post a Comment