Skip to content

Instantly share code, notes, and snippets.

@touhidrahman
Last active August 24, 2022 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save touhidrahman/5d57f211756d1cdf190e60b1600b2904 to your computer and use it in GitHub Desktop.
Save touhidrahman/5d57f211756d1cdf190e60b1600b2904 to your computer and use it in GitHub Desktop.
export class PaginationComponent {
// ...
getNavigablePages(): number[] {
const pages = []
const left = Math.max(1, this.currentPage - this.windowSize)
const right = Math.min(this.totalPages, this.currentPage + this.windowSize)
for (let i = left; i <= right; i++) {
pages.push(i)
}
return pages
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment