fix(router): create a route tree when creating the router service
Closes #8365
This commit is contained in:
parent
277b1fc473
commit
ca13f1c024
|
@ -46,6 +46,7 @@ export class Router {
|
||||||
private _componentResolver: ComponentResolver,
|
private _componentResolver: ComponentResolver,
|
||||||
private _urlSerializer: RouterUrlSerializer,
|
private _urlSerializer: RouterUrlSerializer,
|
||||||
private _routerOutletMap: RouterOutletMap, private _location: Location) {
|
private _routerOutletMap: RouterOutletMap, private _location: Location) {
|
||||||
|
this._prevTree = this._createInitialTree();
|
||||||
this._setUpLocationChangeListener();
|
this._setUpLocationChangeListener();
|
||||||
this.navigateByUrl(this._location.path());
|
this.navigateByUrl(this._location.path());
|
||||||
}
|
}
|
||||||
|
@ -62,6 +63,12 @@ export class Router {
|
||||||
|
|
||||||
dispose(): void { ObservableWrapper.dispose(this._locationSubscription); }
|
dispose(): void { ObservableWrapper.dispose(this._locationSubscription); }
|
||||||
|
|
||||||
|
private _createInitialTree(): RouteTree {
|
||||||
|
let root = new RouteSegment([new UrlSegment("", null, null)], null, DEFAULT_OUTLET_NAME,
|
||||||
|
this._rootComponentType, null);
|
||||||
|
return new RouteTree(new TreeNode<RouteSegment>(root, []));
|
||||||
|
}
|
||||||
|
|
||||||
private _setUpLocationChangeListener(): void {
|
private _setUpLocationChangeListener(): void {
|
||||||
this._locationSubscription = this._location.subscribe(
|
this._locationSubscription = this._location.subscribe(
|
||||||
(change) => { this._navigate(this._urlSerializer.parse(change['url'])); });
|
(change) => { this._navigate(this._urlSerializer.parse(change['url'])); });
|
||||||
|
|
Loading…
Reference in New Issue