我有5列的角material 表.我知道我可以将Active属性设置为任何列,但有没有办法在开始时按降序对所有列进行排序,而对活动列按升序进行排序?
我试过这个:
@ViewChild(MatSort)排序:MatSort;
<table matSort matSortActive="orderColumn">
this.dataSource.sort = this.sort;
const sortState: Sort = {active: 'orderColumn', direction: 'desc'};
this.sort.active = sortState.active;
this.sort.direction = 'desc';
this.sort.sortChange.emit(sortState);
根据我在这里找到的答案:Default sorting in Angular Material - Sort header
但这并不奏效.
谢谢!