Skip to content

Commit 999c42a

Browse files
fix(ng2.UISrefActive): Use @ContentChildren to query for the nested UISref
Closes #2950
1 parent 44dfdec commit 999c42a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ng2/directives/uiSrefStatus.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @module ng2_directives */ /** */
2-
import {Directive, Output, EventEmitter} from "@angular/core";
2+
import {Directive, Output, EventEmitter, ContentChild} from "@angular/core";
33
import {StateService} from "../../state/stateService";
44
import {UISref} from "./uiSref";
55
import {PathNode} from "../../path/node";
@@ -9,7 +9,7 @@ import {TargetState} from "../../state/targetState";
99
import {TreeChanges} from "../../transition/interface";
1010
import {State} from "../../state/stateObject";
1111
import {anyTrueR, tail, unnestR} from "../../common/common";
12-
import {UIRouterGlobals, Globals} from "../../globals";
12+
import {Globals} from "../../globals";
1313
import {Param} from "../../params/param";
1414
import {PathFactory} from "../../path/pathFactory";
1515

@@ -44,6 +44,7 @@ export class UISrefStatus {
4444

4545
// current statuses of the state/params the uiSref directive is linking to
4646
@Output("uiSrefStatus") uiSrefStatus = new EventEmitter<SrefStatus>(false);
47+
@ContentChild(UISref) sref: UISref;
4748

4849
status: SrefStatus = {
4950
active: false,
@@ -54,12 +55,11 @@ export class UISrefStatus {
5455

5556
constructor(transitionService: TransitionService,
5657
private _globals: Globals,
57-
private _stateService: StateService,
58-
public sref: UISref) {
58+
private _stateService: StateService) {
5959
this._deregisterHook = transitionService.onStart({}, $transition$ => this.processTransition($transition$));
6060
}
6161

62-
ngOnInit() {
62+
ngAfterContentInit() {
6363
let lastTrans = this._globals.transitionHistory.peekTail();
6464
if (lastTrans != null) {
6565
this.processTransition(lastTrans);

0 commit comments

Comments
 (0)