reset paginator first page angular material
You need to use a ViewChild
decorator to select the paginator and then set the pageIndex
property of the paginator.
@ViewChild() paginator: MatPaginator;
...
this.paginator.pageIndex = 0;
Edit: As suggested by the other answers, if you would like to reset the paginator to the first page, it would be better to use this.paginator.firstPage()
<mat-paginator #paginator [length]="length"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
(page)="pageEvent = paginationClicked($event)">
</mat-paginator>
@ViewChild('paginator') paginator: MatPaginator;
this.paginator.firstPage();
Create a referecne for material angular paginator along with data source
dataSource: MatTableDataSource<any>;
@ViewChild(MatPaginator) paginator: MatPaginator;
You want to reset the paginator using the following code
this.dataSource.paginator = this.paginator;
You can also reset by calling the first page method of the paginator
this.paginator.firstPage();