I am trying to display a table with a large collection of elements. I want to paginate the table and load only the elements displayed on the current page. Now, the json is loaded with $resource
.
I read here that it's a good idea to pass the pagination infos (currentPage, pagesCount and elementsCount) inside the json header.
How can I access to those infos which are 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' });
}]);
Operations and Engineering Dashboards supports server side pagination grid. Server side pagination is considered useful for large-sets of data as the amount of data that is transferred to the client is much smaller than the data handled by the client.
Server-Side Paging (Angular) Server-side paging consists of making requests that bring in one page of data at a time. The actual commands used to retrieve the data depend on the API exposed by the server.
Server-side pagination is a way of controlling a subset of data requests that were fetched from a client-side server, and are useful if we don't want to display all of the data at once. Server-side pagination requires the client to pass in a parameter in order to fetch the relevant information.
Pagination in AngularJS is a technique of dividing the contents of a particular large page into small pages and showing them in an indexed format in order. This technique is very popular in designing search engines in which, the most relatable content is presented on a priority basis.
Based on the AngularJS $resource documentation, it should be possible to do this:
List.query({offset: 0, limit: 100, sortType: 'DESC' }, function(data, responseHeaders) {
// you can access headers here
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With