Reputation: 1457
I want to access an existing formBuilder and set value of a specific object. The problem is that is not a normal formbuilder. It is a formbuilder inside another.
code:
formBuilder.group({
nasty: formBuilder.group({
myobject: ['', []],
})});
How can I set value on myobject?
Upvotes: 2
Views: 895
Reputation: 316
This is just a FormGroup
within a FormGroup
.
You could just patchValue
whole form object.
this.form.patchValue({ nasty: { myobject: 'POPULATED' }})
Or you could target specific one.
this.form.get('nasty.something').patchValue('AND THIS TOO');
Here is StackBlitz with example -> https://stackblitz.com/edit/angular-3wpxsy
Upvotes: 3