В ваших component.ts замените этот код
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
следующим:
private paginator: MatPaginator;
private sort: MatSort;
@ViewChild(MatSort) set matSort(ms: MatSort) {
this.sort = ms;
this.setDataSourceAttributes();
}
@ViewChild(MatPaginator) set matPaginator(mp: MatPaginator) {
this.paginator = mp;
this.setDataSourceAttributes();
}
setDataSourceAttributes() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
И в вашем html:
<mat-card *ngIf="!dataSource?.filteredData.length" style="margin-bottom: 5px">
<div><span>ZERO RESULT</span></div>
</mat-card>
<mat-card *ngIf="dataSource?.filteredData.length">
** insert the table code that you have **
</mat-card>