cleanup(router): make names consistent
This commit is contained in:
parent
89704e0f93
commit
3aa2606ff1
|
@ -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);
|
||||
|
|
|
@ -52,14 +52,14 @@ export class Router {
|
|||
return this._navigate(this._urlSerializer.parse(url));
|
||||
}
|
||||
|
||||
navigate(changes: any[], segment?: RouteSegment): Promise<void> {
|
||||
return this._navigate(this.createUrlTree(changes, segment));
|
||||
navigate(commands: any[], segment?: RouteSegment): Promise<void> {
|
||||
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<RouteSegment>(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); }
|
||||
|
|
Loading…
Reference in New Issue