javascript - AngularJS with AngularUI Bootsrap pagination directive doesn't hide results -


i'm trying use angular-ui pagination directive first time , confused why isn't working. can see pagination buttons , displays 2 pages paginate through since there 8 results , items-per-page="5" data items showing , not being hidden 5 per page.

controller

dataservice.get(uri).then(function (data) {      $scope.testimonials = data;      $scope.totalitems = $scope.testimonials.length;     $scope.currentpage = 1;      $scope.setpage = function(pageno) {         $scope.currentpage = pageno;     };      $scope.pagechanged = function() {         console.log('page changed to: ' + $scope.currentpage);     } }); 

view

<table class="table table-striped" ng-show="testimonials.length">     <thead>       <th>name</th>       <th>message</th>     </thead>     <tbody>     <tr ng-repeat="testimonial in testimonials">       <td>{{testimonial.name}}</td>       <td>{{testimonial.message}}</td>       <td><a href="testimonials/{{testimonial.id}}" class="btn btn-primary">edit</a></td>       <td><button class="btn btn-danger" ng-click="delete(testimonial)">delete</button></td>     </tr>     </tbody>      <pagination total-items="totalitems" ng-model="currentpage" items-per-page="5" ng-change="pagechanged()"></pagination> </table> 

i appreciate advice, thanks!

yo need filter data in ng-reapeter code below should works

<table class="table table-striped" ng-show="testimonials.length">     <thead>       <th>name</th>       <th>message</th>     </thead>     <tbody>     <tr ng-repeat="testimonial in testimonials | startfrom: (currentpage-1)*5| limitto: 5">       <td>{{testimonial.name}}</td>       <td>{{testimonial.message}}</td>       <td><a href="testimonials/{{testimonial.id}}" class="btn btn-primary">edit</a></td>       <td><button class="btn btn-danger" ng-click="delete(testimonial)">delete</button></td>     </tr>     </tbody>      <pagination total-items="totalitems" ng-model="currentpage" items-per-page="5" ng-change="pagechanged()"></pagination> </table> 

filter starts from:

app.filter('startfrom', function () {     return function (input, start) {            if (input === undefined || input === null || input.length === 0          || start === undefined || start === null || start.length === 0 || start === nan) return [];         start = +start; //parse int          try {             var result = input.slice(start);             return result;          } catch (e) {          //    alert(input);         }      } }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -