mat-filtering/mat-sort not work correctly when use ngif in mat-table parent

前端 未结 5 1840
甜味超标
甜味超标 2021-02-08 13:02

Note that paging/sort not work correctly. Paging does not show the number of elements it is showing and sorting does not work, but if you delete the line in the html file

5条回答
  •  孤独总比滥情好
    2021-02-08 13:26

    This can be solved by the following strategy:

    dataSource = new MatTableDataSource();
    
    @ViewChild(MatSort, {static: false}) set content(sort: MatSort) {
      this.dataSource.sort = sort;
    }
    

    Now even if you use *ngIf, it will work.

提交回复
热议问题