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
Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for '@routeAnimations': 'undefined'. Current value: 'NewAnimationName'. #36173
Comments
|
#36222 also had a minimal repro that's a bit smaller: https://github.com/fxck/angular-animation-cd-bug |
|
I have the same issue in angular 9.1. |
|
I have the same issue. I think this is an important issue. The [hidden] attribute is a good substitute (sometimes) but if I need to wait for information before rendering the child routes, the ngif is really necessary. A resolver might work as well, but that simply doesn't work for my use case all the time. |
|
This bug exists in Angular 10, as well. |
|
core.js:6185 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'. There is any solution for this bug? |
|
Did anyone find something on this? core.js:6272 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'. The link should call backend API for showing some data but I get this error instead. |
|
Hi, did anyone find how to fix this ? Same problem as @acohenOT, error pops up when @routerAnimations directive is in a *ngIf. Edit Ok i found a fix that worked for me, kinda dirty but it works: 1- Inject changeRef service
|
|
I am also getting this issue when attempting to use activated route data to trigger route animation. The animation works, just want to get rid of the error message to keep from hampering future debugging when we haven't been working in this project for a while. This is using Angular 9.2.4 |
|
I found this https://angular.io/errors/NG0100 |
|
+1 Getting same error. |
|
Same issue Angular 12.0.3 |
|
This Fixed the problem for me : <main [@routeAnimations]="prepareRoute(outlet)">
<router-outlet class="route" #outlet="outlet"></router-outlet>
</main>import { RouterOutlet } from '@angular/router';
import { AfterViewInit, ChangeDetectorRef } from '@angular/core';
export class HomeComponent implements AfterViewInit {
constructor(private changeRef: ChangeDetectorRef) { }
ngAfterViewInit(): void {
this.changeRef.detectChanges();
}
prepareRoute(outlet: RouterOutlet) {
return outlet?.activatedRouteData?.animation;
}
} |
|
For what it's worth I think that this is not at all animations related I think the issue is related to the I've created a minimal reproduction which doesn't use animations anywhere (it does not even import the animations module): https://github.com/dario-piotrowicz/angular-expressionchanged-router-bug (the important bit is just in the PS: this still happens in Angular 13 as you can see from the repo |
|
This happens because the template attempts to read from the activated route data, which isn't updated until Angular does not support reading values from a component which change during change detection before the component executes. The reason this works when the outlet element is always present (rather than conditionally) is because the We could consider activating the outlet in the Instead, the way this should be done is through the public context data. For Dario's example, this would be @dario-piotrowicz Would you like to take a look at the documentation and update it to not show this backwards reference data access? |
@atscott sure! I'd love to! Feel free to assign the issue to me if you want |
|
Thanks @atscott |
developers should not access the router-outlet directive in their template before defining a template variable for it, such implementation is present in a couple of aio guides, fix such guides so that they show the more correct way of accessing the outlet's data resolves angular#36173
developers should not access the router-outlet directive in their template before defining a template variable for it, such implementation is present in a couple of aio guides, fix such guides so that they show the more correct way of accessing the outlet's data resolves angular#36173
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |


RouteAnimationError.zip
Affected Package
Not clear.Possibly @angular/animations or @angular/router
Is this a regression?
Yes, the previous version in which this bug was not present was: 8.3Description
Using route animation with a parent element that is conditionally hidden, causes ExpressionChangedAfterItHasBeenCheckedError. This did not happen in Angular 8.3. Began with Angular 9.
Possibly related to issue #34821.
Error occurs with
No error occurs with
Unable to recreate in stackblitz. See attached min repro project.
Steps:
The text was updated successfully, but these errors were encountered: