fix(router): init is not triggered in certain scenarios

This commit is contained in:
vsavkin 2016-06-08 22:45:05 -07:00
parent 2fef30f619
commit 2d4be1c9eb
1 changed files with 6 additions and 2 deletions

View File

@ -61,9 +61,13 @@ export function provideRouter(config: RouterConfig): any[] {
// APP_INITIALIZER -> Router) // APP_INITIALIZER -> Router)
setTimeout(_ => { setTimeout(_ => {
const appRef = injector.get(ApplicationRef); const appRef = injector.get(ApplicationRef);
appRef.registerBootstrapListener((_) => { if (appRef.componentTypes.length == 0) {
appRef.registerBootstrapListener((_) => {
injector.get(Router).initialNavigation()
});
} else {
injector.get(Router).initialNavigation() injector.get(Router).initialNavigation()
}); }
}, 0); }, 0);
return _ => null; return _ => null;
}, },