11/** @module ng2 */ /** */
22import { UIRouter } from "../router" ;
3- import { Directive } from "angular2/core" ;
3+ import { Directive , Inject } from "angular2/core" ;
44import { Optional } from "angular2/core" ;
5- import { Input } from "angular2/core" ;
65import { ElementRef } from "angular2/core" ;
76import { Renderer } from "angular2/core" ;
7+ import { UiView } from "./uiView" ;
8+ import { ViewContext } from "../view/interface" ;
9+ import { extend } from "../common/common" ;
810
911@Directive ( { selector : 'a[uiSref]' } )
1012export class AnchorUiSref {
11- constructor ( public _el : ElementRef , public _renderer : Renderer ) { }
13+ constructor ( public _el : ElementRef , public _renderer : Renderer ) { }
1214 update ( href ) {
13- this . _renderer . setElementProperty ( this . _el , 'href' , href ) ;
15+ this . _renderer . setElementProperty ( this . _el . nativeElement , 'href' , href ) ;
1416 }
1517}
1618
@@ -26,6 +28,7 @@ export class UiSref {
2628
2729 constructor (
2830 private _router : UIRouter ,
31+ @Inject ( UiView . INJECT . context ) public context : ViewContext ,
2932 @Optional ( ) private _anchorUiSref : AnchorUiSref
3033 ) { }
3134
@@ -39,12 +42,17 @@ export class UiSref {
3942
4043 update ( ) {
4144 if ( this . _anchorUiSref ) {
42- this . _anchorUiSref . update ( this . _router . stateService . href ( this . state , this . params ) ) ;
45+ this . _anchorUiSref . update ( this . _router . stateService . href ( this . state , this . params , this . getOptions ( ) ) ) ;
4346 }
4447 }
4548
49+ getOptions ( ) {
50+ let defOpts = { relative : this . context . name , inherit : true } ;
51+ return extend ( defOpts , this . options || { } ) ;
52+ }
53+
4654 go ( ) {
47- this . _router . stateService . go ( this . state , this . params , this . options ) ;
55+ this . _router . stateService . go ( this . state , this . params , this . getOptions ( ) ) ;
4856 return false ;
4957 }
5058}
0 commit comments