我有一个基于以下内容的输入框:
如果更改无线电,我会看到该值变为 true 或 false:
<pre> {{model_parameters_general.estimationmethod=='ew'}} </pre>
那么哇为什么输入框会根据true为false而被禁用呢?
<input [disabled]="model_parameters_general.estimationmethod=='ew'" [(ngModel)]="model_parameters_general.lambda"
formControlName="lambda" type="text" class="form-control">
EDIT:
在日志中我得到这个:
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
you. We recommend using this approach to avoid 'changed after checked' errors.
Example:
form = new FormGroup({
first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
last: new FormControl('Drew', Validators.required)
});
所以我使用了 rc6 中的响应式。
我将初始禁用设置为以下内容:
this.myForm = fb.group({
lambda: new FormControl({value: .99, disabled: true}, Validators.required),
})
那么我是否可以根据无线电输入的切换来启用?
尝试使用 attr.disabled,而不是禁用
<input [attr.disabled]="disabled?'':null"/>
堆栈溢出答案
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)