我有这个带有复选框的选择。我想禁用并检查字符串数组中存在的那些。如果值存在于我的角度 .ts 文件中的数组中,我将如何添加disabled和属性。checkedthis.claimNames = any[];<div class="row container"> <div *ngFor="let reno of renoList" class="form-group form-check col-md-3"> <input type="checkbox" class="form-check-input" disabled checked> <label class="form-check-label">{{reno}}</label> </div></div>
1 回答
慕尼黑8549860
TA贡献1818条经验 获得超11个赞
您可以使用.includes()
试试这样:
工作演示
.html
<div class="row container">
<div *ngFor="let reno of renoList" class="form-group form-check col-md-3">
<input type="checkbox" class="form-check-input" [disabled]="claimNames.includes(reno)" [checked]="claimNames.includes(reno)">
<label class="form-check-label">{{reno}}</label>
</div>
</div>
.ts
renoList:any[] = ["A", "B", "C"];
claimNames:any[] = ["A"]
添加回答
举报
0/150
提交
取消
