Answer the question
In order to leave comments, you need to log in
Why doesn't the OnChanges() hook fire when the onPush strategy is disabled?
I'm trying to work with the onPush strategy and I see strange results. Please help me figure it out. I will show 2 pages, there is an error in only one of them.
On THIS page, I use the onPush strategy and get the expected result:
Answer the question
In order to leave comments, you need to log in
The reference to your object does not change. The OnChanges hook only fires the first time in both examples and doesn't fire again because the reference to the object doesn't change, since it's still the same object, even if the content of the object has changed. In the second case, the template is redrawn because the onPush strategy is disabled. In order for the object changes to be processed during the onPush strategy, there are 2 options: create a new object or use the DoCheck hook and write the change detection logic yourself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question