From 545caab433a776546d52b7bbd803ce179e07d65e Mon Sep 17 00:00:00 2001 From: vsavkin Date: Wed, 8 Jun 2016 19:38:15 -0700 Subject: [PATCH] fix(router): use bootstrap listener to trigger initial navigation --- modules/@angular/router/src/common_router_providers.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/@angular/router/src/common_router_providers.ts b/modules/@angular/router/src/common_router_providers.ts index a01c99f12c..01f8df5070 100644 --- a/modules/@angular/router/src/common_router_providers.ts +++ b/modules/@angular/router/src/common_router_providers.ts @@ -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]