fix(router): use bootstrap listener to trigger initial navigation

This commit is contained in:
vsavkin 2016-06-08 19:38:15 -07:00
parent 3f90659cc1
commit 545caab433
1 changed files with 6 additions and 1 deletions

View File

@ -59,7 +59,12 @@ export function provideRouter(config: RouterConfig): any[] {
// 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);
setTimeout(_ => {
const appRef = injector.get(ApplicationRef);
appRef.registerBootstrapListener((_) => {
injector.get(Router).initialNavigation()
});
}, 0);
return _ => null;
},
deps: [Injector]