1

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.

Cem Kocagöz
  • 634
  • 12
  • 26
  • According to the [documentation](https://material.angular.io/components/paginator/api) there is a "firstPage()" method. Haven't tried it, tho, but I guess it should work – dquijada Dec 17 '18 at 09:19
  • i saw that and tried import MatPaginatorModule, MatPaginator and use this method like MatPaginatorModule.firstPage() but i dont think its not the way to use it. Do you have any idea about how to use methods? btw thanks for your reply. – Cem Kocagöz Dec 17 '18 at 09:31
  • [How to use paginator](https://stackoverflow.com/questions/45318164/how-to-use-paginator-from-material-angular) – Prashant Pimpale Dec 17 '18 at 09:43
  • i dont think this link include solution for my answer. i could go to first page with buttons. but i want done this automatically when a value has changed. – Cem Kocagöz Dec 17 '18 at 10:31

1 Answers1

2

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;
Cem Kocagöz
  • 634
  • 12
  • 26