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'])); });