How to do server side pagination using angularjs $ resource?

I am trying to display a table with a large set of elements. I want to paginate pages and only load the elements that appear on the current page. Now json loads using $resource .

I read here that it’s nice to pass the pagination information (currentPage, pagesCount and elementsCount) inside the json header.

How can I access the information that is in the json header from angular?

Here is the basic js structure:

 angular.module('App.services', ['ngResource']). factory('List', function($resource){ return $resource('url/of/json/:type/:id', {type:'@type', id:'@id'}); }); angular.module('App.controllers', []). controller('ListCtrl', ['$scope', 'List', function($scope, List) { var $scope.list= List.query({offset: 0, limit: 100, sortType: 'DESC' }); }]); 
+11
angularjs
Jul 04 '13 at 0:03
source share
1 answer

Based on the AngularJS $ resource documentation, this should be possible:

 List.query({offset: 0, limit: 100, sortType: 'DESC' }, function(data, responseHeaders) { // you can access headers here }); 
+14
Jul 04 '13 at 0:14
source share



All Articles