form( [formGroup]="form" )
div( '[formGroupName]'="formGroupName" )
.form-group
label
| Address
input.form-control(
type="text"
formControlName="address"
)
div(formArrayName="sub_addresses_attributes")
div(
'*ngFor'="let sub_addresses_attribute of form.get('sub_addresses_attributes')['controls']; let i=index"
)
div( '[formGroupName]'="i" )
.form-group
label
| Address
input.form-control(
type="text"
formControlName="address"
)
I would like to create a component or partial or template that can DRY-up the code above.
This is may parent/main component: parent.component.ts
this.fb.group({
'sub_addresses_attributes': this.fb.array([]),
'address_attributes': {
'id': [],
'address': []
}
}
Here the partial component I am trying to create
div( '[formGroup]'="FROM_@INPUT" )
div( '[formGroupName]'="FROM_@INPUT" )
.form-group
label
| Address
input.form-control(
type="text"
formControlName="address"
)
However, formGroupName is required for the address_attributes, while not on formArray.