javascript - Angular paging generates wrong number of pages -


i having hard time getting angular paging work correctly. number of pages seems off. example, 1 of searches, number of returned results 1005. displaying 16 results per page, should have 63 pages total. instead generates 101. appreciate suggestions on why happening , how resolve.

thanks in advance!

<table class="table table-striped results">                     <thead>                         <tr>                             <th ng-repeat="x in json.headers">{{ x }}</th>                         </tr>                     <thead>                     <tbody>                         <tr ng-repeat="x in filteredresults">                             <td><a href="#">{{ x.name }}</a></td>                             <td>{{ x.city }}</td>                             <td>{{ x.state }}</td>                             <td>{{ x.zip }}</td>                             <td>{{ x.phone }}</td>                         </tr>                     </tbody>                     </ul>                 </table>                 <pagination                                              style="position:absolute; bottom:10px;"                                     ng-show="json.results.length"                                   ng-model="currentpage"                                   total-items="json.results.length"                                   max-size="maxsize"                                     boundary-links="true"                                   next-text=">"                                   last-text=">>"                                   previous-text="<"                                   first-text="<<">                 </pagination> 

javascript

var app = angular.module('myapp', ['ui.bootstrap']);         app.controller('formctrl', function($scope, $http){              $(document).ready(function(){                 $('.submit-search').click(function(){                     $http.get('model/search_url.php', {                         params: { searchby: $scope.user.searchby, search: $scope.user.search }                     }).success(function (response){                         $scope.json = response;                         $scope.filteredresults = [];                         $scope.currentpage = 1                         $scope.numperpage = 16                         $scope.maxsize = 5;                          $scope.$watch("currentpage + numperpage", function() {                             var begin = (($scope.currentpage - 1) * $scope.numperpage);                             var end = begin + $scope.numperpage;                             $scope.filteredresults = $scope.json.results.slice(begin, end);                         });                     });                 });         }); 

you're missing items-per-page, in case should 16, since don't provide it set default of 10 items per page.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -