I\'m having trouble with importing matSort into my matTable.
I\'m providing you with my code:
dashboard.component.ts
So it's happening because of your this.sort.sortChange method is getting called before your child view Initialize
You Just need to implement your class from AfterViewInit instead of OnInit
And use ngAfterViewInit life cycle method
export class ApplicantListComponent implements AfterViewInit {
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator;
@ViewChild(MatSort, { static: false }) sort: MatSort;
constructor() {}
ngAfterViewInit() {
this.sort.sortChange.subscribe(() => {
this.paginator.pageIndex = 0;
this.paginator.pageSize = this.pageSize;
});
}