From the API I'm working on I need to take 2 different lists and I need to take in chunks of 20 items to avoid server timeouts.
What I built actually is this:
Items1.query().$promise
.then(function (data) {
$scope.items1 = data.list;
return Items2.query().$promise;
})
.then(function (data) {
$scope.items2 = data.list;
});
With this code I'm downloading the entire list of objects.
Both the query return:
{
list: [...],
next: true,
limit: 20,
last: 20
}
Basically it is a pagination system.
Both services are like this:
App.factory('Items1', ['$resource',
function($resource) {
return $resource('items1/:item1Id', { storeId: '@id'
}, {
query: {
method: 'GET',
isArray: false
},
update: {
method: 'PUT'
}
});
}
]);
I don't really know how to make recursive function with $resource in order to push those items in chunks of 20.
nextvalue isfalsequery()only returns 20 you need another method that sets the start point