0

I want to implement uib-pagination , I have data in $scope.event based on that i want to display pagination but its not showing pagination directive itself , Any idea what is implemented wrong i do not see any error in console. Or any better approach to achieve this task ?

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."
}]
4
  • expose your $scope.event json. Commented Sep 16, 2016 at 17:01
  • @Aravind added to question Commented Sep 16, 2016 at 17:05
  • try to set currentPage to 0. Try to define limit on repeat Commented Sep 16, 2016 at 17:10
  • oh oh. you have just 4 values then how come your pagination will work! Commented Sep 16, 2016 at 18:32

1 Answer 1

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

see plunker: http://plnkr.co/edit/YLCmEoTzhUz312X2htuB?p=preview

Sign up to request clarification or add additional context in comments.

2 Comments

I see its working in plunker, I applied your code and i see pagination element displayed but its not working items-per-page is set to 5 , I do not page 2 when we logs more than 5.
Please try to replicate it on my plunker or just create a new one with not working pagination and I will try to fix it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.