i am little confuse about push data into control because i using control inside nested control i have no idea how i push data inside the nested control this is my component.ts code
mileStoneForm:FormGroup;
constructor(private fb:FormBuilder) {
this.mileStoneForm = this.fb.group({
milestone:this.fb.array([])
});
createMilestone()
{
return this.fb.group({
name:[''],
date:[''],
description:[''],
value:[''],
approval:[''],
deliverable:this.fb.array([
this.createMilestoneDeliverable()
])
});
}
createMilestoneDeliverable()
{
return this.fb.group({
title:[''],
description:[''],
excluded:['']
});
}
addNewDeliverable()
{
return (this.mileStoneForm.get('milestone').get('deliverable') as
FormArray).controls.push(this.createMilestoneDeliverable());
}
this add function is used to store data in deliverable field i want to push this.createMilestoneDeliverable() function data into deliverable field help me guys i am so confuse i can not fix it with myself
return (this.mileStoneForm.get(['milestone','deliverable']) as FormArray).push(this.createMilestoneDeliverable());?createMilestonefunction call andmileStoneFormform in your questiondeliverablein your form and yourmilestoneis the formArray instead of formGroup