Javascript 如何有条件地设置角材料垫表单元?
我有以下mat表,每个记录都有编辑和删除按钮:Javascript 如何有条件地设置角材料垫表单元?,javascript,angular,typescript,angular-material,mat-table,Javascript,Angular,Typescript,Angular Material,Mat Table,我有以下mat表,每个记录都有编辑和删除按钮: Name | Operation | -------|-----------------| Bob | Edit | Delete | John | Edit | Delete | Willy | Edit | Delete | 我使用的垫台结构如下所示: <ng-container matColumnDef="operation"> <th mat-heade
Name | Operation |
-------|-----------------|
Bob | Edit | Delete |
John | Edit | Delete |
Willy | Edit | Delete |
我使用的垫台结构如下所示:
<ng-container matColumnDef="operation">
<th mat-header-cell *matHeaderCellDef>Operation</th>
<td mat-cell *matCellDef="let row">
<ng-container *ngFor="let operation of operations">
<button [disabled]="row.isActive">
<mat-icon>{{ operation.icon }}</mat-icon>
</button>
</ng-container>
</td>
</ng-container>
那么,是否可以使用从父组件以字符串等形式发送的这两个条件来操作单个按钮?您可以使用回调来验证它 比如:
您是否进行了必要的评估。谢谢,朋友,投票通过了。但是我需要一个通用的解决方案,通过从父组件传递条件。有什么想法吗?
this.operation = [
{
type: 'delete',
condition: 'row.isActive && operation.type === "delete"'
}
];