Skip to content

Commit

Permalink
Merge pull request #374 from SergiiPototskyi/master
Browse files Browse the repository at this point in the history
Show 1 as default page number instead of empty when there are no items
  • Loading branch information
michaelbromley committed May 10, 2021
2 parents ed5c789 + 0cceb2b commit 15fe2ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pagination-controls.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ export class PaginationControlsDirective {
// paginationRange could be a string if passed from attribute, so cast to number.
paginationRange = +paginationRange;
let pages = [];
const totalPages = Math.ceil(totalItems / itemsPerPage);

// Return 1 as default page number
// Make sense to show 1 instead of empty when there are no items
const totalPages = Math.max(Math.ceil(totalItems / itemsPerPage), 1);
const halfWay = Math.ceil(paginationRange / 2);

const isStart = currentPage <= halfWay;
Expand Down

0 comments on commit 15fe2ed

Please sign in to comment.