I just want to add that there is another Lifecycle hook called DoCheck
that is useful if the @Input
value is not a primitive value.
I have an Array as an Input
so this does not fire the OnChanges
event when the content changes (because the checking that Angular does is 'simple' and not deep so the Array is still an Array, even though the content on the Array has changed).
I then implement some custom checking code to decide if I want to update my view with the changed Array.