Please explain to me why I keep getting this error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.
Obviously,
My issue was manifest when I added *ngIf
but that wasn't the cause. The error was caused by changing the model in {{}}
tags then trying to display the changed model in the *ngIf
statement later on. Here's an example:
{{changeMyModelValue()}}
....
{{myModel.value}}
To fix the issue, I changed where I called changeMyModelValue()
to a place that made more sense.
In my situation I wanted changeMyModelValue()
called whenever a child component changed the data. This required I create and emit an event in the child component so the parent could handle it (by calling changeMyModelValue()
. see https://angular.io/guide/component-interaction#parent-listens-for-child-event