繁体   English   中英

如何使用ng-repeat和angular-ui-bootstrap创建分页?

[英]How to create pagination using ng-repeat with angular-ui-bootstrap?

我想实现uib-pagination,我在$scope.event有数据,我想显示分页,但是它本身没有显示分页指令,任何想法实现错误我都不会在控制台中看到任何错误。 还是有更好的方法来完成此任务?

main.html

<div class="panel-body display-logs" scroll-bottom="event">
                <ul style="list-style: none;">
                    <li ng-repeat="message in event track by message.id" ng-class="{lastItem: $last}"><span><strong>Log:</strong></span><span>{{message.value}}</span></li>
                </ul>
            </div>

    <uib-pagination total-items="event.length" ng-model='currentPage' items-per-page='pageSize' boundary-links="true">
                </uib-pagination>

Ctrl.js

$scope.event = [];
 $scope.pageSize=5,
 $scope.currentPage=1;

event.json

[{
    "id": 0,
    "value": "Lorem test Ipsuver since the 1500s,but also the leap into electronic typesetting, remaining essentially unchanged."
}, {
    "id": 1,
    "value": "-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."
}, {
    "id": 2,
    "value": "19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."
}, {
    "id": 3,
    "value": "ee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."
}]
<div class="panel-body display-logs" scroll-bottom="event">
  <ul style="list-style: none;">
    <li ng-repeat="message in event | limitTo : pageSize : (currentPage - 1) * pageSize track by message.id" 
        ng-class="{lastItem: $last}">
      <strong>{{ message.id }} --- Log: </strong>
      <span>{{ message.value }}</span>
    </li>
  </ul>
</div>

<ul uib-pagination 
    total-items="totalItems" 
    ng-model="currentPage" 
    items-per-page="pageSize"></ul>

请参阅插件: http ://plnkr.co/edit/YLCmEoTzhUz312X2htuB?p=preview

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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