angularjs + ui.bootstrap 分页错误总页数
angularjs + ui.bootstrap pagination wrong total pages number
无法评论主post,所以需要post新问题。
我正在尝试实施 this thread, written by Scotty.NET(评分最高的答案)的分页解决方案,但面临一个奇怪的问题:
我的自定义代码在这个 plunker(http://plnkr.co/edit/Mdsy2x) 中并解释了这个问题。如果我将 $scope.numPerPage
设置为“10”以外的任何数字 - 我得到的总页数有误。例如,如果我生成 450 个待办事项并设置为 $scope.numPerPage = 5;
- 我总共显示 45 页和 225 个项目,因此除 10 以外的任何数字都会给出错误的结果
你只需要添加items-per-page
属性:
<pagination
total-items="todos.length"
items-per-page="numPerPage"
ng-model="currentPage"
max-size="maxSize"
class="pagination-sm"
boundary-links="true">
</pagination>
它的默认值为 10,这就是为什么它在每页 10 个项目时效果很好。
无法评论主post,所以需要post新问题。
我正在尝试实施 this thread, written by Scotty.NET(评分最高的答案)的分页解决方案,但面临一个奇怪的问题:
我的自定义代码在这个 plunker(http://plnkr.co/edit/Mdsy2x) 中并解释了这个问题。如果我将 $scope.numPerPage
设置为“10”以外的任何数字 - 我得到的总页数有误。例如,如果我生成 450 个待办事项并设置为 $scope.numPerPage = 5;
- 我总共显示 45 页和 225 个项目,因此除 10 以外的任何数字都会给出错误的结果
你只需要添加items-per-page
属性:
<pagination
total-items="todos.length"
items-per-page="numPerPage"
ng-model="currentPage"
max-size="maxSize"
class="pagination-sm"
boundary-links="true">
</pagination>
它的默认值为 10,这就是为什么它在每页 10 个项目时效果很好。