我有下一张角度材料的桌子:

<mat-table *ngIf="!waiting" class="table-general table-summary"  #table [dataSource]="dataSource" matSort>
    <mat-header-row class="header_row" *matHeaderRowDef="headerKeys"></mat-header-row>
    <mat-row class="row" *matRowDef="let row; columns: headerKeys;"></mat-row>
    <ng-container *ngFor="let key of headerKeys; let i = index">
      <ng-container matColumnDef="{{key}}">
        <mat-header-cell class="header_name header_{{key}}" *matHeaderCellDef mat-sort-header> {{getHeaderName(key)}} </mat-header-cell>
        <mat-cell class="cell cell_{{key}}" *matCellDef="let row">
          <div class="box_cell {{key}}">
            <div class="current_value ellipsis" *ngIf="key=='customer'">{{cellValue(row[key])}}</div>
            <mh-box-score
              *ngIf="key!='customer'"
              [value]="cellValue(row[key])"
              [type]="cellValue(row[key],'type')+' small'"
              [type_number]="'percent'"
              [previous_value]="cellValue(row[key],'diff')"
              [previous]="cellValue(row[key],'previousLabel')"
            ></mh-box-score>
          </div>
        </mat-cell>
      </ng-container>
    </ng-container>
  </mat-table>

工作很完美。现在我想把标题中排序箭头的位置从after修改为beforeaccording to the documentation
angular - 角 Material 如何从垫子表设置垫子排序标题-LMLPHP
我已经找遍了所有的方法,但是我不能做一些看起来很简单的事情。
请帮帮我,我对角度比较陌生

最佳答案

为了移动箭头,需要使用@Input()arrowPositionmat-sort-headeritem指令<th mat-sort-header="name" arrowPosition='before'>Dessert (100g)</th>应用于dom元素。
Here is a stackblitz example如何将arrowPosition应用于直接从材料示例分叉的各种表头。

07-24 18:18
查看更多