Due to Object.assign elements on root level like
this.model =
{
"old": "foo"
}
and value =
{
"new": "bar"
}
gets merged to
{
"old": "foo",
"new": "bar"
}
but old is not visible anymore and should be removed from the model.
Assignment like this.model = value is also bad because this leads to bad behaviour with two-way data binding. I tried to use assignment with a change event to tell the parent that the child (FormComponent) has changed the model but because FormComponent implements OnChanges I had a loop.
Not the best fix but at least it just iterates through the keys at root level of the model and not into the nested structure.
Due to
Object.assign
elements on root level like this.model =and value =
gets merged to
but
old
is not visible anymore and should be removed from the model.Assignment like
this.model = value
is also bad because this leads to bad behaviour with two-way data binding. I tried to use assignment with a change event to tell the parent that the child (FormComponent
) has changed the model but becauseFormComponent
implementsOnChanges
I had a loop.Not the best fix but at least it just iterates through the keys at root level of the model and not into the nested structure.