feat(router): auxiliary routes

Closes #2775
This commit is contained in:
Brian Ford
2015-07-17 13:36:53 -07:00
parent 96e34c1d36
commit ac6227e434
24 changed files with 1482 additions and 986 deletions

View File

@ -3,6 +3,7 @@ import {List, StringMap, StringMapWrapper} from 'angular2/src/facade/collection'
import {Router} from './router';
import {Location} from './location';
import {Instruction, stringifyInstruction} from './instruction';
/**
* The RouterLink directive lets you link to specific parts of your app.
@ -43,19 +44,23 @@ export class RouterLink {
// the url displayed on the anchor element.
visibleHref: string;
// the url passed to the router navigation.
_navigationHref: string;
// the instruction passed to the router to navigate
private _navigationInstruction: Instruction;
constructor(private _router: Router, private _location: Location) {}
set routeParams(changes: List<any>) {
this._routeParams = changes;
this._navigationHref = this._router.generate(this._routeParams);
this.visibleHref = this._location.normalizeAbsolutely(this._navigationHref);
this._navigationInstruction = this._router.generate(this._routeParams);
// TODO: is this the right spot for this?
var navigationHref = '/' + stringifyInstruction(this._navigationInstruction);
this.visibleHref = this._location.normalizeAbsolutely(navigationHref);
}
onClick(): boolean {
this._router.navigate(this._navigationHref);
this._router.navigateInstruction(this._navigationInstruction);
return false;
}
}