question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for '@routeAnimations': 'undefined'. Current value: 'NewAnimationName'.

See original GitHub issue

RouteAnimationError.zip

🐞 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.3

Description

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:

  1. Unzip attached project
  2. Run npm install
  3. Run ng serve --open=true
  4. Navigate to /home URL
  5. Open Developer tools, notice error
screenshot

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:21
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

30reactions
hhsissicommented, Aug 27, 2020

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 interface

ngAfterViewChecked(): void { this.changeRef.detectChanges(); }

6reactions
acohenOTcommented, Aug 8, 2020

This bug exists in Angular 10, as well.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found