fix(router): fix lazy loading issues

This commit is contained in:
vsavkin 2016-06-08 19:00:47 -07:00
parent 29a7c4538c
commit 131914ac94
1 changed files with 9 additions and 3 deletions

View File

@ -55,8 +55,14 @@ export function provideRouter(config: RouterConfig): any[] {
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
multi: true, multi: true,
useFactory: (router: Router) => router.initialNavigation(), useFactory: (injector) => {
deps: [Router] // https://github.com/angular/angular/issues/9101
// Delay the router instantiation to avoid circular dependency (ApplicationRef ->
// APP_INITIALIZER -> Router)
setTimeout(_ => injector.get(Router).initialNavigation(), 0);
return _ => null;
}, },
deps: [Injector]
}
]; ];
} }