Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for '@routeAnimations': 'undefined'. Current value: 'NewAnimationName'.
See original GitHub issueπ bug report
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 https://github.com/angular/angular/issues/34821.
Error occurs with
<div *ngIf="!mobileQuery.matches">
<div [@routeAnimations]="prepareRoute(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
</div>
</div>
No error occurs with
<div>
<div [@routeAnimations]="prepareRoute(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
</div>
</div>
π¬ Minimal Reproduction
Unable to recreate in stackblitz. See attached min repro project.
Steps:
- Unzip attached project
- Run npm install
- Run ng serve --open=true
- Navigate to /home URL
- Open Developer tools, notice error

Issue Analytics
- State:
- Created 4 years ago
- Reactions:21
- Comments:17 (6 by maintainers)
Top Results From Across the Web
ExpressionChangedAfterItHasBe...
I was having trouble with . ERROR: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value ...
Read more >NG0100: Expression has changed after it was checked - Angular
Angular throws an ExpressionChangedAfterItHasBeenCheckedError when an expression value has been changed after change detection has completed.
Read more >Angular Debugging "Expression has changed": Explanation ...
Learn a complete explanation about ExpressionChangedAfterItHasBeenCheckedError: why it occurs, how to troubleshoot it and how to fix it.
Read more >ExpressionChangedAfterItHasBe...
Forum Thread - ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'null: undefined'.
Read more >ExpressionChangedAfterItHasBe...
The infamous ExpressionChangedAfterItHasBeenCheckedError error is among ... current value when the subsequent change detection cycle is run.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
constructor(private changeRef: ChangeDetectorRef) { }
Implement AfterViewChecked interfacengAfterViewChecked(): void { this.changeRef.detectChanges(); }
This bug exists in Angular 10, as well.