The issue can be seen in this stackblitz :
I have a payload :
payload = {
id: 1,
name: 'This is the payload',
children: [
{ id: 1, name: 'Child 1' }
],
};
I create a form group out of that :
this.form = this.fb.group(this.payload);
I then display the value of the form :
{{ form?.value | json }}
And the result is :
{ "id": 1, "name": "This is the payload", "children": { "id": 1, "name": "Child 1" } }
As you can see, the children property went from an array, to an object.
- How did that happen ?
- Is it possible to stop Angular from doing that ?
- If I need to use a formArray, is there a way to make it automatic ?