angularJS中的分页问题

时间:2017-03-20 01:23:52

标签: angularjs pagination

我有一个分页的问题,我没有看到用这个代码分页的按钮(1,2,3 ......)

    <div ng-controller="PaginationDemoCtrl">
    <table class="table">
      <tr ng-repeat="row in data.slice(((currentPage-1)*itemsPerPage), ((currentPage)*itemsPerPage))">
        <td>{{row.name}}</td>
        <td>{{row.id}}</td>
      </tr>
    </table>
          <select ng-model="viewby" ng-change="setItemsPerPage(viewby)">
    <option>3</option>
    <option>5</option>
    <option>10</option>
    <option>20</option>
    <option>30</option>
    <option>40</option>
    <option>50</option>
          </select>

    <pagination total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()" class="pagination-sm" items-per-page="itemsPerPage"></pagination>
    <pre>The selected page no: {{currentPage}}</pre>
    <button class="btn btn-info" ng-click="setPage(3)">Set current page to: 3</button>

    <hr />
    <h4>Pager</h4>
    <pager total-items="totalItems" ng-model="currentPage" items-per-page="itemsPerPage"></pager>

    <hr />
    <h4>Limit the maximum visible buttons</h4>
    <pagination total-items="totalItems" ng-model="currentPage" max-size="maxSize" class="pagination-sm" boundary-links="true" items-per-page="itemsPerPage"></pagination>
    <pagination total-items="totalItems" ng-model="currentPage" max-size="maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages" items-per-page="itemsPerPage"></pagination>
    <pre>Page: {{currentPage}} / {{numPages}}</pre>
  </div>

我不明白为什么?

我分享一个玩家,这是第二个表

http://plnkr.co/edit/6qzk1CaeoPYUD1GVudtg?p=preview

如果有人可以帮助我

提前致谢

1 个答案:

答案 0 :(得分:1)

使用var str = " absolutely pie"; var indices = [0, 12, 16]; // indices where I want to insert var things = ["I", "love", 1]; // things I want to insert for(var i = 0; i < indices.length; i++) { str = str.splice(indices[i], 0, things[i]); } 代替uib-pagination。此外,该指令仅适用于属性,而不适用于元素。所以,你应该考虑做这样的事情:

pagination

The documentation有一个很好的例子。