我有一个表单数组的表单:
this.myForm = this._fb.group({
id: [this.model.id],
customer_id: [this.model.customer_id],
orderlines: this._fb.array([])
});
表单数组:
return this._fb.group({
id: [orderline.id],
order_id: [orderline.order_id],
factor: [orderline.factor],
})
现在我想在方法setFactor(i)中更改factor字段的值 . i是表单数组顺序的索引 .
setFactor(i) {
this.myForm['orderlines'[i]].patchValue({ factor: 99 }) <--- no error but no change in form
this.myForm.patchValue({ orderlines[i].factor: 99 }) <-- error
}
如何使用patchValue更改表单数组中的值?
编辑
这将给我我想要改变的 Value :
console.log(this.myForm['controls']['orderlines']['controls'][i]['controls']['factor'].value);
1 回答
以下工作: