Skip to content

Commit 0586874

Browse files
authored
fix(router): use injector to fix cyclic dependency with APP_INITIALIZER and router
Fix cyclic dependency when using APP_INITIALIZER closes TrilonIO#54
2 parents e36bd61 + ee3df01 commit 0586874

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/app-insight.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, Optional } from '@angular/core';
1+
import { Injectable, Optional, Injector } from '@angular/core';
22
import { Router, NavigationStart, NavigationEnd, NavigationCancel, NavigationError } from '@angular/router';
33
import { AppInsights } from 'applicationinsights-js';
44
import { filter } from 'rxjs/operators';
@@ -52,7 +52,7 @@ export class AppInsightsService implements IAppInsights {
5252

5353
constructor(
5454
@Optional() _config: AppInsightsConfig,
55-
public router: Router
55+
private _injector: Injector
5656
) {
5757
this.config = _config;
5858
}
@@ -257,5 +257,9 @@ export class AppInsightsService implements IAppInsights {
257257
console.warn('You need forRoot on ApplicationInsightsModule, with or instrumentationKeySetlater or instrumentationKey set at least');
258258
}
259259
}
260+
261+
private get router() {
262+
return this._injector.get(Router);
263+
}
260264
}
261265

0 commit comments

Comments
 (0)