New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExpressionChangedAfterItHasBeenCheckedError when you combine onLazyLoad and loading tags #8465
Comments
Should be fixed on your side I think; lazyLoadCallback(event) {
Promise.resolve(null).then(() => this.loading = true); |
@cagataycivici So your recommended solution is to update the value outside of Angular's change detection scope rather than fix the lifecycle hooks?... |
@Michael-Ziluck I had the same issue and in my case initialize loading variable with true in variable definition solved the issue, I know that this should work either way but at least it is a good workaround, no need for setTimeout. |
This is really sick!. I have a http interceptor to fire loading indicator for all http request. More or less it looks like this:
and
and me too I get the same error because of wrong lifecycle hooks. And I had to use setTimeout to make it work. @cagataycivici keep in mind that people may want to use their solutions with loading indicator so it sholud work as expected! |
I'm submitting a ... (check one with "x")
Plunkr Case (Bug Reports)
https://stackblitz.com/edit/github-ap6ryb
Current behavior
When you set
loading = true
within theonLazyLoad
callback, Angular throws anExpressionChangedAfterItHasBeenCheckedError
.Expected behavior
No such error should be thrown.
Minimal reproduction of the problem with instructions
See the stackblitz link above.
What is the motivation / use case for changing the behavior?
Being able to display the loading spinner while the content is loading should be a pretty standard feature.
Temporary Workaround:
Wrap everything within the callback method in a
setTimeout
block. Here is a forked version of the stackblitz I linked above that has this change: https://stackblitz.com/edit/github-ap6ryb-khx7a2Please tell us about your environment:
Every environment encounters this error.
Angular version: All versions.
PrimeNG version: All versions
Browser: All
Language: All
This issue is similar to #3293 and #3041 but they are NOT the same. I did my research to make sure there are no existing issues and if there are solutions online.
I am aware of the fact that you can either use
ChangeDetectorRef
or simply wrap it in asetTimeout
block. However, I feel like this should be supported natively. It seems odd that you can't combine them without using other workarounds.The text was updated successfully, but these errors were encountered: