0

On loading a table, I need to move the user to a specific page e.g. If a table has 10 pages I need to move the user to Page 8 instead of user having to click 8 times to get to page 8. I am using Angular Material Table and Paginator.

Rajan
  • 1
  • If you have presented a minimum setup of code of what you have, in the question, then others will be able to help you a lot. – Nipuna Saranga Jan 07 '21 at 22:36

1 Answers1

0

Set pageIndex from pageEvent. here is the code

pageChange(pageEvent: PageEvent) {
if (pageEvent.pageIndex > pageEvent.previousPageIndex)
   this.readMoreRecords();
   this.pageSize = pageEvent.pageSize;
   this.pageIndex = pageEvent.pageIndex;

}

<mat-paginator [pageSize]='5' 
               (page)="pageChange($event)"
               [pageSizeOptions]='[5, 10, 15, 25]' showFirstLastButtons>
</mat-paginator>
Rajan
  • 1