我如何禁用Angular 2中的复选框 [英] how can I disable checkboxes in angular 2
本文介绍了我如何禁用Angular 2中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想禁用复选框输入,我的意思是,用户无法选中de checkbox
I want to disable a checkbox input, I mean, the user can not check de checkbox
有一个属性可以禁用此功能吗?像[启用]或[禁用]?或我该如何解决?
there is an atribute to disable this? like [enable] or [disable]? or how can I fix this?
<input type="checkbox" name="isActive" [(ngModel)]="user.isActive">
有什么主意吗?
推荐答案
如果您使用反应形式,则可以在正确的方法中使用类似的方法:
If you are using reactive forms, you can use something like this in the right methods:
要禁用:
this.myform.controls['chkUpdate'].disable();
要启用:
this.myform.controls['chkUpdate'].enable();
这篇关于我如何禁用Angular 2中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文