问题
Im using material paginator for paging some custom cards. And i made a selector for filter the data. I want to trigger paginator go to first page event when i changed the selector value. Because for example while im looking at page 10 and changed filter value paginator show me the empty page if i dont have enough data to show at 10.page.
回答1:
I solved my problem. Solution; import
import { MatPaginator } from '@angular/material';
this at your .ts file. (not app.module.ts)
add this to same file
@ViewChild(MatPaginator) paginator: MatPaginator;
call this funtion at your selector data change event
this.paginator.firstPage();
lastly you should change your paginator length, i made this like that;
this.paginator.length=mock.length;
来源:https://stackoverflow.com/questions/53811943/angular-material-paginator-how-to-trigger-go-to-first-page-event-on-ts-file