patchValue formArray 3级Angular 8

时间:2020-06-30 06:56:18

标签: angular

我有一个FormGroup:

this.rooms = new FormGroup({
      room:  this._fb.array([
        this._fb.group({
          adultQuantity: [2],
          childQuantity: [0],
          childrenAges: this._fb.array([
            new FormControl('', Validators.required)
          ])
        })
      ])
    });

数据从API获取:

room: [{
    adultQuantity: 2,
    childQuantity: 1,
    childrenAges: [3,5]
},
{
    adultQuantity: 2,
    childQuantity: 2,
    childrenAges: [3,2,9]
}]

如何将数据修补到FormGroup会议室。
抱歉,我英语不好。
谢谢大家。

1 个答案:

答案 0 :(得分:0)

您可以像这样修补表格,

[0] => thisisline = aline

这可能会帮助您https://stackblitz.com/edit/deep-nested-reactive-form