【问题标题】:How to use pagination on table using angular-ui如何使用angular-ui在表格上使用分页
【发布时间】:2017-06-19 23:22:13
【问题描述】:

这是我的代码。我试过了,但它显示了所有记录,并且分页似乎不起作用。

<div id="lead-casts" class="row" ng-show="showAllCast" width="auto" ng-init="getAllCast()">
<div class="col-sm-12">
    <h1 align="center">All Cast</h1>
    <table class="table table-striped">
        <th align="center"><h4>NAME</h4></th>
        <th align="center"><h4>ROLE</h4></th>
        <tbody>
        <tr ng-repeat="cast in allCast">
            <td>{{ cast.name }}</td>
            <td>{{ cast.role }}</td>
        </tr>
        </tbody>
    </table>
    <pagination total-items="totalItems" items-per-page="20" ng-model="currentPage"></pagination>
    <button class="btn btn-danger pull-left" ng-click="showCast()">Back</button>
    <button class="btn btn-info pull-right" ng-click="showCast()">Next</button>
</div>

我也尝试在 ng-repeat 上使用 limitTo 过滤器,但它仅将显示限制为 20 个项目。

<tr ng-repeat="cast in allCast | limitTo: 20">

如何将记录或 ng-repeat 绑定到分页?

【问题讨论】:

    标签: javascript html angularjs html-table angularjs-ng-repeat


    【解决方案1】:

    使用 startFrom 和 limitTo 这里是 jsfiddle demohttp://jsfiddle.net/2ZzZB/56/

    【讨论】:

      猜你喜欢
      • 2020-04-06
      • 2013-11-05
      • 2020-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-26
      • 1970-01-01
      • 2020-06-03
      相关资源
      最近更新 更多