From 3fd4ecbfc46a4ce4a1afda861f576bab51a34070 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 16 Jan 2020 14:47:37 +0100 Subject: [PATCH] 67611: ExpressionChangedAfterItHasBeenCheckedError fix --- src/app/app.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1f3da086c2..2141b06a77 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { filter, map, take } from 'rxjs/operators'; +import { delay, filter, map, take } from 'rxjs/operators'; import { AfterViewInit, ChangeDetectionStrategy, Component, HostListener, Inject, OnInit, ViewEncapsulation } from '@angular/core'; import { NavigationCancel, NavigationEnd, NavigationStart, Router } from '@angular/router'; @@ -125,8 +125,11 @@ export class AppComponent implements OnInit, AfterViewInit { } ngAfterViewInit() { - this.router.events - .subscribe((event) => { + this.router.events.pipe( + // This fixes an ExpressionChangedAfterItHasBeenCheckedError from being thrown while loading the component + // More information on this bug-fix: https://blog.angular-university.io/angular-debugging/ + delay(0) + ).subscribe((event) => { if (event instanceof NavigationStart) { this.isLoading = true; } else if (