AngularJs Bootstrap pagination using ng-repeat not working properly -


i'm trying implement bootstrap pagination on ng-repeat.

html

<tr data-ng-repeat="userdetails in data.slice(((currentpage-1)*itemsperpage), ((currentpage)*itemsperpage)) |filter:status:status.status" >          <td>{{userdetails.status.status}}</td>       <td> {{ userdetails.subdate | date : 'mm-dd-yyyy' }} </td>       <td> {{ userdetails.fullname }} </td>       <td> {{ userdetails.servicetype.servicename }} </td>       <td> {{ userdetails.status.status }} </td>  </tr> <select ng-model="viewby" ng-change="setitemsperpage(viewby)"><option>5</option><option>10</option></select> records @ time.  <uib-pagination total-items="totalitems" ng-model="currentpage" ng-change="pagechanged()" class="pagination-sm" items-per-page="itemsperpage"></uib-pagination> 

js

$http.get('getalldetails').success(function(response)     {         $scope.data = response;         $scope.totalitems = $scope.data.length;         $scope.viewby = 10;         $scope.currentpage = 1;         $scope.itemsperpage = $scope.viewby;         $scope.maxsize = 5; //number of pager buttons show          $scope.setpage = function (pageno) {             $scope.currentpage = pageno;         };          $scope.setitemsperpage = function(num) {             $scope.itemsperpage = num;             $scope.currentpage = 1;              }                    }) 

problem if set 10 items per page, shows random number of items 7 items in first page, 9 items in next page , goes on. tried adding ui-bootstrap-tpls.js no luck.

you see seeing results because paging being applied before filtering. page size 10, 10 items selected, filter runs leaving 7 or 9 items or many of 10 satisfy filter.

this can fixed rearranging ng-repeat code this, ensure filter applied first:

<tr data-ng-repeat="userdetails in (data | filter:status:status.status).slice(((currentpage-1)*itemsperpage), ((currentpage)*itemsperpage)) " >    

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -