我需要禁用formControl,还需要使用该函数获取数据。
我使用以下代码禁用输入文本字段
(formControlNames:- numberPrefix,numberFormat,resetNumberFormat )
onChanges() {
this.soPreferenceFormGroup.get('numberPrefix').disable();
this.soPreferenceFormGroup.get('numberFormat').disable();
this.soPreferenceFormGroup.get('resetNumberFormat').disable();
}
下面是获取我got.Only numberMode的结果。
然后,当我在模板方法中直接使用禁用的函数时,如下所示
<input pInputText type="text" formControlName="numberPrefix" class="form-control" placeholder="Required" disabled />
<input pInputText type="text" formControlName="numberFormat" class="form-control" placeholder="Required" disabled/>
<input pInputText type="text" formControlName="resetNumberFormat" class="form-control" placeholder="Required" disabled />
现在,所有的formGroup值都是获取的,.Below就是截图。
为什么在禁用方法时不显示值?
我希望禁用并获取该函数的值,而不是直接写入html模板。
有人能帮我吗?
请验证此stackBlitz:链接
发布于 2019-05-27 03:08:47
form.value
返回窗体的所有活动属性。
如果希望使用禁用的值,请使用myForm.getRawValue()
https://stackoverflow.com/questions/56324887
复制相似问题