diff --git a/modules/@angular/router/src/directives/router_link.ts b/modules/@angular/router/src/directives/router_link.ts index a34b0610a9..c2278fd275 100644 --- a/modules/@angular/router/src/directives/router_link.ts +++ b/modules/@angular/router/src/directives/router_link.ts @@ -22,7 +22,7 @@ import {ObservableWrapper} from '../facade/async'; @Directive({selector: '[routerLink]'}) export class RouterLink implements OnDestroy { @Input() target: string; - private _changes: any[] = []; + private _comands: any[] = []; private _subscription: any; @HostBinding() private href: string; @@ -37,21 +37,22 @@ export class RouterLink implements OnDestroy { @Input() set routerLink(data: any[]) { - this._changes = data; + this._comands = data; this._updateTargetUrlAndHref(); } + @HostListener("click") onClick(): boolean { if (!isString(this.target) || this.target == '_self') { - this._router.navigate(this._changes, this._routeSegment); + this._router.navigate(this._comands, this._routeSegment); return false; } return true; } private _updateTargetUrlAndHref(): void { - let tree = this._router.createUrlTree(this._changes, this._routeSegment); + let tree = this._router.createUrlTree(this._comands, this._routeSegment); if (isPresent(tree)) { this.href = this._router.serializeUrl(tree); this.isActive = this._router.urlTree.contains(tree); diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index 3a656c9baf..e729aaecc3 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -52,14 +52,14 @@ export class Router { return this._navigate(this._urlSerializer.parse(url)); } - navigate(changes: any[], segment?: RouteSegment): Promise { - return this._navigate(this.createUrlTree(changes, segment)); + navigate(commands: any[], segment?: RouteSegment): Promise { + return this._navigate(this.createUrlTree(commands, segment)); } dispose(): void { ObservableWrapper.dispose(this._locationSubscription); } private _createInitialTree(): RouteTree { - let root = new RouteSegment([new UrlSegment("", null, null)], null, DEFAULT_OUTLET_NAME, + let root = new RouteSegment([new UrlSegment("", {}, null)], {}, DEFAULT_OUTLET_NAME, this._rootComponentType, null); return new RouteTree(new TreeNode(root, [])); } @@ -85,13 +85,9 @@ export class Router { }); } - createUrlTree(changes: any[], segment?: RouteSegment): UrlTree { - if (isPresent(this._prevTree)) { - let s = isPresent(segment) ? segment : this._prevTree.root; - return link(s, this._prevTree, this.urlTree, changes); - } else { - return null; - } + createUrlTree(commands: any[], segment?: RouteSegment): UrlTree { + let s = isPresent(segment) ? segment : this._prevTree.root; + return link(s, this._prevTree, this.urlTree, commands); } serializeUrl(url: UrlTree): string { return this._urlSerializer.serialize(url); }