fix(router): fix router to take root component type instead of instance

This commit is contained in:
vsavkin 2016-05-31 08:48:53 -07:00
parent 91d64a2855
commit 8407cfeac7
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { ComponentResolver, ReflectiveInjector } from '@angular/core';
import { ComponentResolver, ReflectiveInjector, Type } from '@angular/core';
import { Location } from '@angular/common';
import { UrlSerializer } from './url_serializer';
import { RouterOutletMap } from './router_outlet_map';
@ -33,9 +33,9 @@ export class Router {
/**
* @internal
*/
constructor(private rootComponent:Object, private resolver: ComponentResolver, private urlSerializer: UrlSerializer, private outletMap: RouterOutletMap, private location: Location) {
constructor(private roorComponentType:Type, private resolver: ComponentResolver, private urlSerializer: UrlSerializer, private outletMap: RouterOutletMap, private location: Location) {
this.currentUrlTree = createEmptyUrlTree();
this.currentRouterState = createEmptyState(<any>rootComponent.constructor);
this.currentRouterState = createEmptyState(roorComponentType);
this.setUpLocationChangeListener();
this.navigateByUrl(this.location.path());
}

View File

@ -27,7 +27,7 @@ describe("Integration", () => {
{
provide: Router,
useFactory: (resolver, urlSerializer, outletMap, location) =>
new Router(new RootCmp(), resolver, urlSerializer, outletMap, location),
new Router(RootCmp, resolver, urlSerializer, outletMap, location),
deps: [ComponentResolver, UrlSerializer, RouterOutletMap, Location]
},
{provide: ActivatedRoute, useFactory: (r) => r.routerState.root, deps: [Router]},