refactor(router): Switch from using APP_COMPONENT binding to a manual ROUTER_PRIMARY_COMPONENT binding.

With the coming bootstrapping changes, a single application (and thus Router) can have multiple root components. One of these needs to be identified as the "primary" component from which the Router will load its configuration. This is now done by providing a ROUTER_PRIMARY_COMPONENT binding to the primary component type.
This commit is contained in:
Alex Rickabaugh
2015-09-03 12:55:08 -07:00
parent 4f57990d45
commit 193792c27f
5 changed files with 47 additions and 27 deletions

View File

@ -457,13 +457,12 @@ export class Router {
export class RootRouter extends Router {
_location: Location;
constructor(registry: RouteRegistry, location: Location, hostComponent: Type) {
super(registry, null, hostComponent);
constructor(registry: RouteRegistry, location: Location, primaryComponent: Type) {
super(registry, null, primaryComponent);
this._location = location;
this._location.subscribe((change) =>
this.navigateByUrl(change['url'], isPresent(change['pop'])));
this.registry.configFromComponent(hostComponent);
this.registry.configFromComponent(primaryComponent);
this.navigateByUrl(location.path());
}