更新时间:2023-02-14 21:10:02
由于只想更改控件 id
的值,因此应使用 patchValue
代替 setValue
方法可修改该formControl的值.
Since you want to change only the value of the control id
, you should use patchValue
instead of setValue
method to modify the value of that formControl.
this.subcategoryForm.patchValue({
id:res.result.Name
});
如果要使用 setValue
方法,则可以从formControl id
调用它:
if you want to use setValue
method, you can call it from the formControl id
:
this.subcategoryForm.controls['id'].setValue(res.result.Name);