Last active
August 24, 2022 04:29
-
-
Save touhidrahman/5d57f211756d1cdf190e60b1600b2904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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