Reputation: 821
So I have a nested form like this:
form
- address
- city
- state
- pincode
- name
- phone
now I want to set the value of pincode programatically. How do I set it? I have checked it for the non nested form and found it here: But can't seem to find it for nested forms.
I have tried using dot notation for finding controls.
Upvotes: 0
Views: 254
Reputation: 7231
Try something like this:
Refer Demo to understand form array
Use index
to get controls of FormArray.
form.controls.address.controls[i].controls.pincode.setValue('your_pin')
Upvotes: 2
Reputation: 9687
use form.get('controlName')
this.form.get('address').get('pincode').setValue(selected.id);
Upvotes: 2