码迷,mamicode.com
首页 > 其他好文 > 详细

angular-ui-bootstrap分页指令问题

时间:2016-02-29 19:35:13      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:

html

<div class="pull-right">
  <pagination 
total-items="pagination.totalcount"
items-per-page="pagination.pagesize"
max-size="5"
ng-model="pagination.currentpage"
class="pagination-sm m-t-none m-b"
boundary-links="true"
rotate="false"></pagination> </div>

 

js

$scope.pagination = {
      pagesize: 12,
      totalcount: -1,
      currentpage: 1
    };

var search = function () {
// 每次查询前重置总记录数,会导致分页无效,点击任何分页或下一页会去查询相应页的数据,但随后当前页currentpage会被重置为1
// 解决办法:
// 1. 不重置总记录数
// 2. 页面中使用ng-if或ng-show控制只有当totalcount>pagesize时才显示分页按钮
// $scope.pagination.totalcount = 0; prdListService.getPrds({ cur_page: $scope.pagination.currentpage, ret_rows: $scope.pagination.pagesize }).then(function (data) { if (data && data[0]) { $scope.prds = data[0]; if (data[1]) { $scope.pagination.totalcount = data[1]; } } else { $scope.prds = []; $scope.pagination.totalcount = 0; $scope.pagination.totalpage = 0; } }); }; $scope.$watch("pagination.currentpage", function () { if ($scope.pagination.currentpage <= 1) return; search(); });

  

angular-ui-bootstrap分页指令问题

标签:

原文地址:http://www.cnblogs.com/liug/p/5228549.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!