@@ -6,6 +6,7 @@ import {isPresent} from 'angular2/src/facade/lang';
66import { DOM } from 'angular2/src/dom/dom_adapter' ;
77
88import { Router } from './router' ;
9+ import { Location } from './location' ;
910
1011/**
1112 * The RouterLink directive lets you link to specific parts of your app.
@@ -41,11 +42,13 @@ export class RouterLink {
4142 _route :string ;
4243 _params :any ;
4344 _router :Router ;
45+ _location :Location ;
4446 _href :string ;
4547
46- constructor ( elementRef :ElementRef , router :Router ) {
48+ constructor ( elementRef :ElementRef , router :Router , location : Location ) {
4749 this . _domEl = elementRef . domElement ;
4850 this . _router = router ;
51+ this . _location = location ;
4952 this . _params = StringMapWrapper . create ( ) ;
5053 DOM . on ( this . _domEl , 'click' , ( evt ) => {
5154 evt . preventDefault ( ) ;
@@ -64,10 +67,10 @@ export class RouterLink {
6467 onAllChangesDone ( ) {
6568 if ( isPresent ( this . _route ) && isPresent ( this . _params ) ) {
6669 var newHref = this . _router . generate ( this . _route , this . _params ) ;
67- this . _href = newHref ;
70+ this . _href = this . _location . normalizeAbsolutely ( newHref ) ;
6871 // Keeping the link on the element to support contextual menu `copy link`
6972 // and other in-browser affordances.
70- DOM . setAttribute ( this . _domEl , 'href' , newHref ) ;
73+ DOM . setAttribute ( this . _domEl , 'href' , this . _href ) ;
7174 }
7275 }
7376}
0 commit comments