fix(router): fix router to take root component type instead of instance
This commit is contained in:
parent
91d64a2855
commit
8407cfeac7
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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]},
|
||||
|
|
Loading…
Reference in New Issue