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]'})
|
@Directive({selector: '[routerLink]'})
|
||||||
export class RouterLink implements OnDestroy {
|
export class RouterLink implements OnDestroy {
|
||||||
@Input() target: string;
|
@Input() target: string;
|
||||||
private _changes: any[] = [];
|
private _comands: any[] = [];
|
||||||
private _subscription: any;
|
private _subscription: any;
|
||||||
|
|
||||||
@HostBinding() private href: string;
|
@HostBinding() private href: string;
|
||||||
|
@ -37,21 +37,22 @@ export class RouterLink implements OnDestroy {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set routerLink(data: any[]) {
|
set routerLink(data: any[]) {
|
||||||
this._changes = data;
|
this._comands = data;
|
||||||
this._updateTargetUrlAndHref();
|
this._updateTargetUrlAndHref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@HostListener("click")
|
@HostListener("click")
|
||||||
onClick(): boolean {
|
onClick(): boolean {
|
||||||
if (!isString(this.target) || this.target == '_self') {
|
if (!isString(this.target) || this.target == '_self') {
|
||||||
this._router.navigate(this._changes, this._routeSegment);
|
this._router.navigate(this._comands, this._routeSegment);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _updateTargetUrlAndHref(): void {
|
private _updateTargetUrlAndHref(): void {
|
||||||
let tree = this._router.createUrlTree(this._changes, this._routeSegment);
|
let tree = this._router.createUrlTree(this._comands, this._routeSegment);
|
||||||
if (isPresent(tree)) {
|
if (isPresent(tree)) {
|
||||||
this.href = this._router.serializeUrl(tree);
|
this.href = this._router.serializeUrl(tree);
|
||||||
this.isActive = this._router.urlTree.contains(tree);
|
this.isActive = this._router.urlTree.contains(tree);
|
||||||
|
|
|
@ -52,14 +52,14 @@ export class Router {
|
||||||
return this._navigate(this._urlSerializer.parse(url));
|
return this._navigate(this._urlSerializer.parse(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(changes: any[], segment?: RouteSegment): Promise<void> {
|
navigate(commands: any[], segment?: RouteSegment): Promise<void> {
|
||||||
return this._navigate(this.createUrlTree(changes, segment));
|
return this._navigate(this.createUrlTree(commands, segment));
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose(): void { ObservableWrapper.dispose(this._locationSubscription); }
|
dispose(): void { ObservableWrapper.dispose(this._locationSubscription); }
|
||||||
|
|
||||||
private _createInitialTree(): RouteTree {
|
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);
|
this._rootComponentType, null);
|
||||||
return new RouteTree(new TreeNode<RouteSegment>(root, []));
|
return new RouteTree(new TreeNode<RouteSegment>(root, []));
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,9 @@ export class Router {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createUrlTree(changes: any[], segment?: RouteSegment): UrlTree {
|
createUrlTree(commands: any[], segment?: RouteSegment): UrlTree {
|
||||||
if (isPresent(this._prevTree)) {
|
let s = isPresent(segment) ? segment : this._prevTree.root;
|
||||||
let s = isPresent(segment) ? segment : this._prevTree.root;
|
return link(s, this._prevTree, this.urlTree, commands);
|
||||||
return link(s, this._prevTree, this.urlTree, changes);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serializeUrl(url: UrlTree): string { return this._urlSerializer.serialize(url); }
|
serializeUrl(url: UrlTree): string { return this._urlSerializer.serialize(url); }
|
||||||
|
|
Loading…
Reference in New Issue