Noticed a strange behavior with angular5 forms using the builder to construct a form which contains a form array needed to capture additional dynamic data, the form array values are only updated if
- During creation initial form controls where added to form array
this.formBuilder.array(this.getRow())
- When the first initial control is touched
Angular version 5.2.0 Experimental/Sample Code Here
Point 1/2 Addendum
Changes appear to only be registered on components that are not dynamically added to FormArray
Code where form array element is inclusive of initialization process
ngOnInit(){
this.form = this.formBuilder.group({
name:[null],
description:[null],
hobbies:this.formBuilder.array([this.getRow()])
});
}
getRow():FormGroup{
return this.formBuilder.group({
hobby:[null],
description:[null]
});
}
though it is evident that additional controls where created, they are all empty
However as soon as the first element is touched (noticed change from fishing to fishing4 and console output now has values of remaining dynamically added controls), all new dynamic fields values are propagated