From ca13f1c0248598f66fbb20125e2400920ddd02e2 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Sun, 1 May 2016 14:33:53 -0700 Subject: [PATCH] fix(router): create a route tree when creating the router service Closes #8365 --- modules/angular2/src/alt_router/router.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/angular2/src/alt_router/router.ts b/modules/angular2/src/alt_router/router.ts index 65ea6ad595..cee4c1c72a 100644 --- a/modules/angular2/src/alt_router/router.ts +++ b/modules/angular2/src/alt_router/router.ts @@ -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(root, [])); + } + private _setUpLocationChangeListener(): void { this._locationSubscription = this._location.subscribe( (change) => { this._navigate(this._urlSerializer.parse(change['url'])); });