I am passing a Map to a child component but when I set new key-value pair child component cannot detect it in ngOnChange but the first time it boot only.
Is it a bug or simply not supported?
I am passing a Map to a child component but when I set new key-value pair child component cannot detect it in ngOnChange but the first time it boot only.
Is it a bug or simply not supported?
ngOnChanges
will not be called when there are internal mutations in the input data.
https://vsavkin.com/immutability-vs-encapsulation-90549ab74487
What I usually do is to break the reference to the variable. For an array I use map().
let array:number[] = [1, 2, 3];
let newArray:number[] = array.map(num => num);
You can also look at the OnPush change detection strategy.