我正在使用带有角度材料的 angular 4 来构建一张桌子。我希望在mat-sort-header以下模板上有条件地添加。
<mat-header-cell *matHeaderCellDef mat-sort-header>Id</mat-header-cell>
Run Code Online (Sandbox Code Playgroud)
我尝试了以下代码:
<mat-header-cell *matHeaderCellDef [mat-sort-header]=" column!='id' ? column : false ">Id</mat-header-cell>
Run Code Online (Sandbox Code Playgroud)
但它仍然在该列的表中添加排序标题。
我的整个表格如下所示,并且工作正常,除了排序标题问题:
<mat-table #table1 [dataSource]="records" matSort class="mat-cell">
<ng-container *ngFor="let column of keys" [matColumnDef]="column">
<mat-header-cell *matHeaderCellDef [mat-sort-header]=" column!='actions' ? column : false ">
<p *ngIf=" column!='actions' ">{{ column }}</p>
<button *ngIf=" column=='actions' " mat-icon-button color="primary" (click)="functionA()">
<mat-icon class="indigo-icon" aria-label="Example icon-button with a heart icon">add</mat-icon>
</button>
</mat-header-cell>
<mat-cell *matCellDef="let row; let i=index;">
<p *ngIf=" column!='actions' ">{{ row[column] }}</p>
<button *ngIf=" column=='actions' " mat-icon-button …Run Code Online (Sandbox Code Playgroud)