I have an error that I don't understand with ReactiveForms.
output var from roomsGroup returns an array of object like I wish.
Then I use spread operator to pass all objects to the form group in roomingGroup. But only the first object is set.
I don't know what I have to do to make it work.
Any idea ?
export function roomingGroup (fb: any) {
return fb.group(
...roomsGroup(fb)
);
}
function roomsGroup (fb) {
let output = [];
for (let i = 1; i < 4; i++) {
let nameOfProperty = 'R' + i;
output.push({
[nameOfProperty]: fb.group({
quantity: fb.group({
adult: [''],
child: ['']
})
})
})
}
return output;
}