【发布时间】:2021-06-26 02:17:58
【问题描述】:
我有一个带有禁用属性的表单控件的响应式表单,但是当我尝试使用补丁值更改其值时,它以“未定义”结尾。在此处输入代码
这是表单,当用户输入开始日期和持续时间时,我会自动更改结束日期,因此我需要禁用它:
this.newProcessForm = new FormGroup({
'start_date':new FormControl(null, Validators.required),
'end_date':new FormControl({value: null, disabled: true}, Validators.required),
'ex_duration':new FormControl(null, Validators.required),
})
这是我更改值的地方:
const newEndDate = this.dCalc.SubTaskEndDateCalculation(this.newProcess).toLocaleDateString();
this.newProcessForm.patchValue({
'end_date' : newEndDate
})
它正确显示在模板上,但是当我提交表单时,该字段的值返回 undefined 像这样 img enter image description here
【问题讨论】:
标签: angular-reactive-forms angular11