Please explain to me why I keep getting this error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.
Obviously,
Here's my thoughts on what is happening. I have not read the documentation but am sure this is part of why the error is shown.
*ngIf="isProcessing()"
When using *ngIf, it physically changes the DOM by adding or removing the element every time the condition changes. So if the condition changes before it is rendered to the view (which is highly possible in Angular's world), the error is thrown. See explanation here between development and production modes.
[hidden]="isProcessing()"
When using [hidden]
it does not physically change the DOM
but merely hiding the element
from the view, most likely using CSS
in the back. The element is still there in the DOM but not visible depending on the condition's value. That is why the error will not occur when using [hidden]
.