In DRF ho aggiunto limite impaginazione a 100 'PAGINATE_BY': 100,
dal Restangular si aspetta risultati in forma di array, ho dovuto usare la sottostante funzione di estrattore in meta nel mio angolare modulo appCome aggiungere l'impaginazione in Restangular e Django Rest Framework?
var app = angular.module("myapp", ["restangular"].config(function(
RestangularProvider){
RestangularProvider.setResponseExtractor(function(response, operation, what, url) {
if (operation === "getList") {
var newResponse = response.results;
newResponse._resultmeta = {
"count": response.count,
"next": response.next,
"previous": response.previous
};
return newResponse;
}
return response;
});
});
e il mio controller sembra che
app.controller('DataCtrl',function($scope, Restangular){
var resource = Restangular.all('myapp/api/dataendpoint/');
resource.getList().then(function(data){
$scope.records = data;
});
}
Le informazioni meta non sono disponibili nel controller, come si impagina se sono disponibili più di 100 record?
per la versione più recente di utilizzo addResponseInterceptor restangular() al posto di addResponseExtractor() – Jakobovski