feat(router): add a provider making angular1/angular2 integration easier (#12769)

This commit is contained in:
Victor Savkin
2016-11-09 13:33:33 -08:00
committed by vikerman
parent fe35bc34f6
commit 6e35d13fbc
9 changed files with 174 additions and 9 deletions

View File

@ -278,11 +278,20 @@ export function initialRouterNavigation(
};
}
/**
* A token for the router initializer that will be called after the app is bootstrapped.
*
* @experimental
*/
export const ROUTER_INITIALIZER = new OpaqueToken('Router Initializer');
export function provideRouterInitializer() {
return {
provide: APP_BOOTSTRAP_LISTENER,
multi: true,
useFactory: initialRouterNavigation,
deps: [Router, ApplicationRef, RouterPreloader, ROUTER_CONFIGURATION]
};
return [
{
provide: ROUTER_INITIALIZER,
useFactory: initialRouterNavigation,
deps: [Router, ApplicationRef, RouterPreloader, ROUTER_CONFIGURATION]
},
{provide: APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER}
];
}