Trying to implement pagination with mat paginator without a table. Facing an issue with the error message "Type 'void' is not assignable to type 'PageEvent'" for my pagination method.
This is what I have:
HTML:
<mat-paginator
[length]="length"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
(page)="pageEvent = OnPageChange($event)"> //Error occurs here
</mat-paginator>
Typescript:
//Definitions
//Paginator
length = 100;
pageSize = 10;
pageSizeOptions: number[] = [5, 10, 25, 100];
// MatPaginator Output
pageEvent: PageEvent;
@ViewChild(MatPaginator) paginator: MatPaginator;
//Method for changing pages:
OnPageChange(event: PageEvent){
let startIndex = event.pageIndex * event.pageSize;
let endIndex = startIndex + event.pageSize;
if(endIndex > this.length){
endIndex = this.length;
}
this.pagedList = this.identFiltered.slice(startIndex, endIndex); //identFiltered is the Datasource
}
Seems like there might be an issue with the definition of pageEvent, need to investigate further