[英]Only check the checkbox if the value of ngModel is true
When my checkbox is clicked the value of my ngModel
produto.checked
is set to true
, but in a moment this value is changed to false without a click in the checkbox. 单击我的复选框后,我的
ngModel
produto.checked
的值将设置为true
,但是produto.checked
此值将更改为false,而无需在复选框中单击。 How can i make my checkbox only check/uncheck according by my ngModel
? 我怎样才能使我的复选框仅根据
ngModel
检查/取消选中?
I try something like: 我尝试类似的东西:
<tr *ngFor="let produto of sortedDataProduto; let i = index">
<input [checked]="produto.checked" [(ngModel)]="produto.checked" name="checkedproduto{{i}}" type="checkbox">
</tr>
Delete from your code [checked]="produto.checked
". 从您的代码中删除
[checked]="produto.checked
”。 [(ngModel)]="produto.checked"
is enough to show initial value. [(ngModel)]="produto.checked"
足以显示初始值。
You are binding your produto.checked
twice use either [checked]
or [(ngModel)]
您正在绑定您的
produto.checked
使用[checked]
或[(ngModel)]
两次[checked]
if you still have problem please be more specific. 如果您仍然有问题,请更具体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.