Angular Material Paginator: How to trigger go to first page event on ts file

依然范特西╮ 提交于 2021-01-29 08:46:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!