Among the 4 buttons, I want to use one of them as a next page button. How to do this?
This is the paginator HTML
<mat-paginator
[pageSize]="2"
[pageSizeOptions]="[2, 4, 6]" showFirstLastButtons>
</mat-paginator>
These are the relevant parts of the typescript code
recordsDataTable:any[]=[ ];
recordsData !: MatTableDataSource<any>;
@ViewChild(MatPaginator) paginator!: MatPaginator;
ngAfterViewInit()
{
this.userservice.getRecords()
.subscribe(
(x)=>
{
this.recordsDataTable=x.data;
this.recordsData= new MatTableDataSource(x.data);
this.recordsData.paginator = this.paginator;
}
)
}
The Paginator component handles the whole pagination logic for you. You don't handle clicks on it's buttons. The component has a
page
event that you can use to handle page changes.