How to solve an Angular Material error: “Property ‘paginator’ has no initializer and is not definitely assigned in the constructor.”
<mat-paginator> component provides navigation for paged information, typically used with a table.
The example of the error
component.ts example code::
@ViewChild(MatPaginator) paginator: MatPaginator;
component.html example code:
<mat-paginator
#paginator
[length]="itemsLength"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
></mat-paginator>
Solution
component.ts example code:
@ViewChild(MatPaginator) paginator: MatPaginator | any = {};