Angular material 属性绑定在ngFor循环中不起作用
当我将我的隐藏属性绑定到变量时,它正在工作,但在Angular material 属性绑定在ngFor循环中不起作用,angular-material,angular7,Angular Material,Angular7,当我将我的隐藏属性绑定到变量时,它正在工作,但在ngFor值的循环中插入绑定时不工作 我试过像这样[hidden]=“!(column.key)”和hidden=“!{{column.key}}”和hidden=“{{!column.key}}”它不是这样工作的,而是直接绑定到像[hidden]=“!name”这样的变量时工作的 我的名字是一个布尔变量 <table mat-table [dataSource]="dataSource"> <ng-container m
ngFor
值的循环中插入绑定时不工作
我试过像这样[hidden]=“!(column.key)”和hidden=“!{{column.key}}”和hidden=“{{!column.key}}”它不是这样工作的,而是直接绑定到像[hidden]=“!name”这样的变量时工作的
我的名字是一个布尔变量
<table mat-table [dataSource]="dataSource">
<ng-container matColumnDef="{{column.key}}" *ngFor="let column of displayedColumns">
<th mat-header-cell *matHeaderCellDef [hidden]="!(column.key)"> {{column.key}} </th>
<td mat-cell *matCellDef="let element" [hidden]="!(column.key)"> {{element[column.value]}} </td>
</ng-container>
</ng-container>
<tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr>
<tr mat-row *matRowDef="let row; columns: columnsToDisplay;"></tr>
</table>
{{column.key}}
{{element[column.value]}
隐藏属性应该是这样工作的,因为
列.key
的值与变量名相同。您可以使用*ngIf
而不是[hidden]
*ngIf=“!(column.key)”
将起作用您可以使用*ngIf
而不是[hidden]
*ngIf=“!(column.key)”
会起作用的我已经试过了,你不能在一个元素@Shankarlal上使用多个结构指令已经试过了,你不能在一个元素@Shankarlal上使用多个结构指令