angularjs + ui.bootstrap分页错页总页数

use*_*987 3 pagination twitter-bootstrap angularjs

无法评论主帖,所以需要发帖新问题.

我正在尝试从Scotty.NET(评价最高的答案)编写的这个帖子中实现分页解决方案,但面临一个奇怪的问题:

我的自定义代码在此plunker(http://plnkr.co/edit/Mdsy2x)中并解释了该问题.如果我设置$scope.numPerPage为除"10"之外的任何数字 - 我的总页数会出错.例如,如果我生成450 todo并且设置$scope.numPerPage = 5;- 我总共得到45页并显示225项,因此除了10之外的任何数字都会给出错误的结果

小智 20

你只需要添加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>
Run Code Online (Sandbox Code Playgroud)

它的默认值是10,这就是为什么它每页只有10个项目才能正常工作.