데이터 테이블이 '이름'열, 기본적으로 오름차순으로 정렬되도록 아래의 각도 재료 코드를 어떻게 변경합니까? 현재 정렬 방향을 나타내는 화살표가 표시되어야합니다.각도 재료의 기본 정렬 - 정렬 헤더
원래 코드 :
<table matSort (matSortChange)="sortData($event)">
<tr>
<th mat-sort-header="name">Dessert (100g)</th>
<th mat-sort-header="calories">Calories</th>
<th mat-sort-header="fat">Fat (g)</th>
<th mat-sort-header="carbs">Carbs (g)</th>
<th mat-sort-header="protein">Protein (g)</th>
</tr>
<tr *ngFor="let dessert of sortedData">
<td>{{dessert.name}}</td>
<td>{{dessert.calories}}</td>
<td>{{dessert.fat}}</td>
<td>{{dessert.carbs}}</td>
<td>{{dessert.protein}}</td>
</tr>
</table>
나는 이런 식으로 뭔가를 시도했지만 작동하지 않습니다가 (더 화살표가 표시되지하지
이
내가 달성하고자하는 것입니다 정렬 된)<table matSort (matSortChange)="sortData($event)" matSortActive="name" matSortStart="asc" matSortDisableClear>
여기 링크는에 있습니다 10
ngOnInit' check [plunker] (https://plnkr.co/edit/hsIXe6eKUX5RmkyVdrdw?p=preview)에서'this.sortData ({active : "name", 방향 : "asc"}) –
@PankajParkar 올바른 해결책이 아닙니다. 표가 정렬되었지만 정렬 헤더에서 알 수 없으며 현재 정렬 방향을 나타내는 화살표가 표시되지 않습니다. –