Not able to patch multiple formArray in a formGroup.
Form
this.usersForm = this.fb.group({
users: this.fb.array([
{
firstName: [""],
lastName: [""],
}
]),
work: this.fb.array([
{
workType: [""],
workTitle: [""],
}
]),
});
I have multiple formArray like these, how to patchValue to it. I tried the below approach but it makes the code too redundant
const formArray = new FormArray([]);
data.work.forEach((s) => {
formArray.push(
this.fb.group({
workType: s.workType,
workTitle: s.workTitle,
})
);
});
this.usersForm.setControl("work", formArray);