简体   繁体   中英

How to use pagination on table using angular-ui

Here is my code. I tried it but it displays all the records and the pagination doesn't seem to work.

<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>

I also tried on using limitTo filter on the ng-repeat but it only limits the display by 20 items.

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

How can I bind the records or ng-repeat to the pagination?

使用startFrom和limitTo这是jsfiddle demo http://jsfiddle.net/2ZzZB/56/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM