AngularJS UI Bootstrap pagination control off by one page -
i trying angular ui boostrap pagination control work table populated web api controller.
i have directive used on pagination control:
app.filter('pagination', function () { return function (input, start) { start = +start; return input.slice(start); }; });
i have following in angular controller:
$scope.currentpage = 0; // max items per page $scope.pagesize = 10; // number of pagination buttons display $scope.numberbuttons = 5; // total items in array $scope.totalitems = 0; // number of pages $scope.numberpages = 0
in view, have following (truncated brevity):
... <tr data-ng-repeat="assettype in assettypes | filter:searchfilter | pagination: currentpage * pagesize | limitto: pagesize | orderby:sorttype:sortreverse"> <td><a href="#/asset-type-details/{{assettype.assettypeid}}">{{ assettype.assettypeid }}</a></td>--> <td>{{ assettype.assettypename }}</td> <td>{{ assettype.active | yesno }}</td> </tr> </table> <uib-pagination ng-show="totalitems" total-items="totalitems" max-size="numberbuttons" ng-model="currentpage" class="pagination-sm" boundary-link-numbers="true" rotate="false"></uib-pagination>
the issue having when view initally comes up, fine. first 10 items (sort id) start ids 1-10 (for example) expected. however, when navigate away first page , navigate first page, items 11-20 instead of 1-10.
the angular filter @ top works fine when use custom pager control angular ui 1 seems off 1 page when navigate away first page.
also, number of items ($scope.totalitems) , pages ($scope.numberpages) being set in controller method, isn't represented here.
any appreciated
edit: 1 other thing noticed when navigate last page, returns no data, whole scope of pagination seems off one.
edit 2: ok, appears got working. had set current page 1 instead of 0:
$scope.currentpage = 1;
then change pagination control subtract 1 (currentpage-1):
<tr data-ng-repeat="assettype in assettypes | filter:searchfilter | pagination: (currentpage-1) * pagesize | limitto: pagesize | orderby:sorttype:sortreverse">
if proves out post answer when allowed to.
as stated n original post, had set current page 1 instead of 0:
$scope.currentpage = 1;
then change pagination control subtract 1 (currentpage-1):
<tr data-ng-repeat="assettype in assettypes | filter:searchfilter | pagination: (currentpage-1) * pagesize | limitto: pagesize | orderby:sorttype:sortreverse">
Comments
Post a Comment