Issue
I am developing a webpage and i have to show list of items with pagination for an api . show when i select a pagesize or click to next page i have to click a method in ts file . but i don't know how to do it . .
html
<mat-paginator
[pageSizeOptions]="[5, 10, 15, 20]"
[pageSize]="5"
aria-label="Select page"
></mat-paginator>
ts file
searchData:responsebody[] =[];
dataSource!: MatTableDataSource<any>;
dataObs$!: Observable<any>;
ngOnInit(): void {
this.setPagination();
}
setPagination() {
this.dataSource = new MatTableDataSource<any>(this.searchData);
this._changeDetectorRef.detectChanges();
this.dataSource.paginator = this.paginator;
this.dataObs$ = this.dataSource.connect();
}
//
nextpageData(pagesize:number,index:number){
}
so when i slect page size or click next page i want to call this method "nextpageData(param1,param2)"
Solution
mat-paginator
has a page
event:
Event emitted when the paginator changes the page size or page index.
<mat-paginator (page)="yourHandler($event)"></mat-paginator>
Answered By - Eugene
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.