【发布时间】:2017-01-12 12:16:42
【问题描述】:
我有一个基于以下内容的输入框:
如果更改收音机,我看到该值更改为 true 为 false:
<pre> {{model_parameters_general.estimationmethod=='ew'}} </pre>
那么哇为什么输入框会根据真为假禁用呢?
<input [disabled]="model_parameters_general.estimationmethod=='ew'" [(ngModel)]="model_parameters_general.lambda"
formControlName="lambda" type="text" class="form-control">
编辑:
在日志中我得到了这个:
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),
})
那么我是否应该根据无线电输入的切换来启用?
【问题讨论】:
-
如果你使用标签形式,你也应该为你的输入添加属性名称
标签: angular