Pagination for Angular 2+
npm install pagination-ng-lib --save
Code for compontent.html
<pgl-pagination
[currentPage]="currentPage"
[totalPages]="totalPages"
[maxPerPage]="maxPerPage"
(pageSelected)="pageSelected($event)">
</pgl-pagination>
Code for component.ts
currentPage = 1;
totalPages = 10;
maxPerPage = 5; // Best to use odd numbers
// Use this function to call API and fetch resourses
// passing the page number "currentPage"
pageSelected(currentPage) {
console.log(currentPage);
}