2016-09-16 8 views
0

uib-paginationを実装したいのですが、$scope.eventのデータがあります。ページネーションを表示したいのですが、そのページングディレクティブ自体は表示されません。何が間違って実装されているかはコンソールにエラーが表示されません。またはこの作業を達成するためのより良いアプローチですか?ng-repeatを使用して角度付きブートストラップを使ってページネーションを作成するにはどうすればよいですか?

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." 
}] 
+0

$ scope.event jsonが公開されています。 – Aravind

+0

@Aravindが質問に追加しました – hussain

+0

currentPageを0に設定しようとしました。繰り返しの制限を定義しようとしました –

答えて

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

plunkerを参照してください。http://plnkr.co/edit/YLCmEoTzhUz312X2htuB?p=preview

+0

あなたのコードを適用したところ、ページ番号の要素が表示されていますが、「ページあたりの項目数」が5に設定されていますが、5を超えるログを記録するとページ2は表示されません。 – hussain

+0

それを私のプランカに複製するか、またはページングを行わないで新しいものを作成してください。私はそれを修正しようとします – Andriy

関連する問題