---更新---
我早些时候发布了这个问题,但没有得到答案。在github的一个博客中,我发现";isButtonDisabled";单独使用将不起作用,并且需要调用函数。在我的代码中,只有在验证了ts中的一些条件后,我才能带来一个布尔值。出了什么问题?
github链接
我尝试过[禁用]或禁用。根据我的打字条件,它不起作用。我有4个按钮,我需要根据我的typescript条件来实现它。我有7个条件需要评估。截至目前,无论情况如何,该按钮都将被禁用。请建议任何其他方法来实现它
HTML
<button type="button" [disabled]="isButtonDisabled"
style="background: #79CEA4 !important;color: #FFFFFF !important;font-size: 13px;font-weight: 600;margin-right: 20px"
class="btn btn-lg" (click)="finish()">FINISH</button>
TS
isButtonDisabled:boolean;
for (var EmployeeList of Employee){
if ((EmployeeList.EmployeeStatus== 'Active') {
this.isButtonDisabled= false;
return 'circle3';
}
else if((EmployeeList.EmployeeStatus== 'Inactive') {
this.isButtonDisabled= true;
return 'circle1';
}
问题是普通的html<button>
将disabled="anything"
解释为禁用。
因此,在Angular中,您可以使用以下方法实现具有属性与不具有属性:
<button [attr.disabled]="isButtonDisabled ? true: null"...