javascript - AngularJS dynamic pagination: how to limit the maximum visible buttons -
after reading lot of pagination plugins, did not understand , created 1 in mongoose, angularjs, express, node stack manually in client code have total number of items in result ( results fetched server on every page alter ) dynamic , not fixed there might real time updates. in ui writing -
div.pagination-user.pull-right a.page.gradient(ng-class="{disabled:currentpage == 0}",ng-click="prevpage()") prev a.page.gradient(ng-repeat="n in range(1,totalitems)",ng-class="{active: n == currentpage}",ng-click="setpage()",ng-bind="n",ng-show="math.abs(currentpage-n)<3") 1 a.page.gradient(ng-class="{disabled:currentpage == pageditems.length-1}",ng-click="nextpage()") next
i tried ng-show attribute check if n current index near currentpage , ng-show if status both ends ( instead of (n-currentpage) used math.abs(currentpage-n) )
i guess going wrong, if there way limit number of page buttons visible in client code can suggest please
if in case controller's code affects follows -
angular.module('app').controller('paginationdemoctrl', function($scope,$filter, mvuser) { $scope.itemsperpage = 2; $scope.currentpage = 1; var paginatedresults = function(page){ var result = mvuser.query({page:page},function(res){ $scope.maxsize = 5; $scope.totalitems = math.ceil(res.count/$scope.itemsperpage); $scope.currentpage = res.current; $scope.pageditems = res.results; },function(err){ console.log("some error"); }) }; $scope.setpage = function () { $scope.currentpage = this.n; paginatedresults($scope.currentpage); }; $scope.prevpage = function () { if ($scope.currentpage > 0) { $scope.currentpage--; paginatedresults($scope.currentpage); } }; $scope.range = function (start, end) { var ret = []; if (!end) { end = start; start = 0; } (var = start; < end; i++) { ret.push(i); } homecoming ret; }; $scope.nextpage = function () { if ($scope.currentpage < $scope.totalitems - 1) { $scope.currentpage++; paginatedresults($scope.currentpage); } }; paginatedresults($scope.currentpage); });
did seek doing pagination #ngtasty ? http://zizzamia.com/ng-tasty/
javascript node.js angularjs pagination
No comments:
Post a Comment