Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add 'go to page' functionality to material pagination in angular

I need to add a 'jump to' functionality to material pagination. it doesn't have built-in method for that so I need to add it manually.

at the moment I have this code:

<mat-paginator [length]="pageLength"
                       [pageSize]="10"
                       [pageSizeOptions]="pageLength | checkPageLength"
                       [showFirstLastButtons]="true">
        </mat-paginator>

and it shows: my current pagination and I need it to have a textbox and a 'go' button for jumping to a specific page since I have many pages.

like image 754
J.Garay Avatar asked Mar 27 '19 00:03

J.Garay


1 Answers

I found a piece of code from here which is working fine for me:

this.paginator.pageIndex = pageNumber;

this.paginator.page.next({      
     pageIndex: pageNumber,
     pageSize: this.paginator.pageSize,
     length: this.paginator.length
});

Working_Example

like image 190
Prashant Pimpale Avatar answered Nov 14 '22 22:11

Prashant Pimpale