ngOnChanges produces changes for every input, even when the objects are unchanged. #403
Closed
Description
Problem: ngOnChanges
seems to always provide all inputs in the SimpleChanges object, even though some inputs are unchanged. Correct behavior would be that only the changed inputs are provided, similar to the Angular implementation.
Repro steps:
- Open stackblitz
- Click on
val1
button, which changes thesomeValue
property onHelloComponent
. - Notice in the console that the following SimpleChanges object is generated. The issue is that
name
should not come up as a change, since it has not changed.
{
"name": {
"previousValue": "World",
"currentValue": "World",
"firstChange": false
},
"someValue": {
"previousValue": "myvalue",
"currentValue": "val1",
"firstChange": false
}
}
My own debugging shows that all bound input properties are always marked as changed. I can work around it for now by checking for equality myself in the ngOnChanges
method of my component, but a fix would of course be preferable.