如何在 Angular 5 中的值为 'No' 时禁用按钮?
How to disable button when value is 'No' in Angular 5?
下面是我的代码,它以 'Yes'
或 'No'
的形式获取序列号,我想在值为 'No'
[=18= 时按 disable
按钮]
{
headerName: this.translate.instant("sutk.inventory.grid.partNumberView.isSerialized"),
field: "isSerialized",
cellRendererFramework: LinkRendererComponent,
cellRendererFrameworkParams: {
onClick: (data: any) => {
this.fetchSerialNumbers(data.itemLocation.inventoryId, 'Inventory');
}
}
}
这是我渲染的单元格:
agInit(params: any): void {
this.params = params;
if (this.params.colDef.cellRendererFrameworkParams && this.params.colDef.cellRendererFrameworkParams.onClick) {
this.parentOnClick = this.params.colDef.cellRendererFrameworkParams.onClick;
}
this.text = eval("params.data." + params.colDef.field);
}
您发布的代码与您的问题不符。
要根据变量值禁用按钮,您的模板应如下所示:
<button [disabled]="!isEnabled">Custom Button</button>
下面是我的代码,它以 'Yes'
或 'No'
的形式获取序列号,我想在值为 'No'
[=18= 时按 disable
按钮]
{
headerName: this.translate.instant("sutk.inventory.grid.partNumberView.isSerialized"),
field: "isSerialized",
cellRendererFramework: LinkRendererComponent,
cellRendererFrameworkParams: {
onClick: (data: any) => {
this.fetchSerialNumbers(data.itemLocation.inventoryId, 'Inventory');
}
}
}
这是我渲染的单元格:
agInit(params: any): void {
this.params = params;
if (this.params.colDef.cellRendererFrameworkParams && this.params.colDef.cellRendererFrameworkParams.onClick) {
this.parentOnClick = this.params.colDef.cellRendererFrameworkParams.onClick;
}
this.text = eval("params.data." + params.colDef.field);
}
您发布的代码与您的问题不符。
要根据变量值禁用按钮,您的模板应如下所示:
<button [disabled]="!isEnabled">Custom Button</button>