Is it It looks like Angular2\'s FormGroup.patchValue() doesn\'t push new elements into an array.
For example something like this:
ngOnInit() {
I hope this will help you. I have a complex object where my object has an object inside and object inside. sorry for my grammar. but i hope my code will help you
ngOnInit() {
this.descriptifForm = this._fb.group({
name: 'ad',
descriptifs: this._fb.array([ this.buildForm() ]),
});
this._service.getData().subscribe(res => {
this.descriptifForm.setControl('descriptifs', this._fb.array(res || []));
});
}
buildA(): FormGroup {
return this._fb.group({
Id: '',
Groups: this._fb.array([ this.buildB() ]),
Title: ''
});
}
buildB(): FormGroup {
return this._fb.group({
Id: '',
Fields: this._fb.array([ this.bbuildC() ]),
Type: ''
});
}
buildC(): FormGroup {
return this._fb.group({
Answers: this._fb.array([ this.buildD() ]),
Code: '',
});
}
buildD(): FormGroup {
return this._fb.group({
Data: ''
});
}