我试图显示一个包含大量元素的表.我想对表进行分页并仅加载当前页面上显示的元素.现在,json已经加载了$resource
.
我在这里读到,在json头中传递分页信息(currentPage,pagesCount和elementsCount)是个好主意.
如何从角度访问json头中的那些信息?
这是基本的js结构:
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' });
}]);
Run Code Online (Sandbox Code Playgroud)
hol*_*ple 14
基于AngularJS $资源文档,应该可以这样做:
List.query({offset: 0, limit: 100, sortType: 'DESC' }, function(data, responseHeaders) {
// you can access headers here
});
Run Code Online (Sandbox Code Playgroud)