diff --git a/npm/ng-packs/packages/core/src/lib/services/router-events.service.ts b/npm/ng-packs/packages/core/src/lib/services/router-events.service.ts index f41dc9bf5e..0e17b37b04 100644 --- a/npm/ng-packs/packages/core/src/lib/services/router-events.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/router-events.service.ts @@ -34,15 +34,12 @@ export class RouterEvents { } protected listenToNavigation(): void { - ( - this.router.events.pipe( - filter(e => e instanceof NavigationEvent.End && !e.url.includes('error')), - ) as Observable - ).subscribe(event => { - // It must be "NavigationTransition" but it is not exported in Angular - //https://github.com/angular/angular/blob/9c486c96827a9282cbdbff176761bc95554a260b/packages/router/src/navigation_transition.ts#L282 - - this.#previousNavigation.set(this.#currentNavigation()); + const routerEvent$ = this.router.events.pipe( + filter(e => e instanceof NavigationEvent.End && !e.url.includes('error')) + ) as Observable; + + routerEvent$.subscribe(event => { + this.#previousNavigation.set(this.currentNavigation()); this.#currentNavigation.set(event.url); }); }