fix(router): create a route tree when creating the router service

Closes #8365
This commit is contained in:
vsavkin 2016-05-01 14:33:53 -07:00 committed by Victor Savkin
parent 277b1fc473
commit ca13f1c024
1 changed files with 7 additions and 0 deletions

View File

@ -46,6 +46,7 @@ export class Router {
private _componentResolver: ComponentResolver,
private _urlSerializer: RouterUrlSerializer,
private _routerOutletMap: RouterOutletMap, private _location: Location) {
this._prevTree = this._createInitialTree();
this._setUpLocationChangeListener();
this.navigateByUrl(this._location.path());
}
@ -62,6 +63,12 @@ export class Router {
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 {
this._locationSubscription = this._location.subscribe(
(change) => { this._navigate(this._urlSerializer.parse(change['url'])); });