bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Pagination does not work for less than 19 items

Open toblender opened this issue 12 years ago • 2 comments

Browser: 33.0.1750.58 beta Chrome

Pagination for less than 19 items does not work.

Example: $scope.totalItems = 20; // 1,2 show up, expecting 1,2,...20

Example: $scope.totalItems = 19; // only 1 shows up, expecting 1,2,...,19 $scope.totalItems = 5; // only 1 shows up, expecting 1,2,3,4,5

toblender avatar Feb 01 '14 14:02 toblender

@toblender you are confusing number of pages with the collection size. The way this directive works is that it accepts 2 arguments:

  • total number of items in a collection
  • number of items per page (defaults to 10).

Based on the above it calculates a number of of pages to display (total number of items / items per page). If you want to specify exact number of pages, just default items per page to 1:

http://plnkr.co/edit/9hHIRgFQDIUgrnj378qb?p=preview

pkozlowski-opensource avatar Feb 01 '14 15:02 pkozlowski-opensource

Thanks that fixed it.

For anyone else that might be confused on how to use this for only 1 item on a page:

<pagination total-items="bigTotalItems" page="bigCurrentPage" max-size="maxSize" class="pagination-sm" boundary-links="true" 
items-per-page="1" 
on-select-page="setPage(page)" 
></pagination>

JS:

     $scope.maxSize = 5;
     $scope.setPage = function (pageNo) {
        $scope.currentPage = pageNo;
        //Do magic here
    };

    $scope.bigTotalItems = 6;
    $scope.bigCurrentPage = 1;

toblender avatar Feb 01 '14 15:02 toblender