I want Angular's Paginator starts from second page when page refreshed but I got this error
ERROR TypeError: Cannot set property 'pageIndex' of undefined
I tried to use delay but it is not a good solution,
HTML
<mat-paginator #paginator
showFirstLastButtons
[length]="length"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
(page)="pageEvent = changePage($event)">
</mat-paginator>
TypeScript
@ViewChild('paginator', { static: true }) paginator;
pageSize = 5;
pageSizeOptions: number[] = [5, 10, 50, 100];
pageEvent: PageEvent;
buttonDisablity = true;
ngOnInit(): void {
this.paginator.pageIndex = 2;
}