From 999c42a847ae576c71b5c9accb4c8a0f74c46270 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Mon, 29 Aug 2016 11:03:42 -0500 Subject: [PATCH] fix(ng2.UISrefActive): Use @ContentChildren to query for the nested UISref Closes #2950 --- src/ng2/directives/uiSrefStatus.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ng2/directives/uiSrefStatus.ts b/src/ng2/directives/uiSrefStatus.ts index ea54a3104..9b1fd96e2 100644 --- a/src/ng2/directives/uiSrefStatus.ts +++ b/src/ng2/directives/uiSrefStatus.ts @@ -1,5 +1,5 @@ /** @module ng2_directives */ /** */ -import {Directive, Output, EventEmitter} from "@angular/core"; +import {Directive, Output, EventEmitter, ContentChild} from "@angular/core"; import {StateService} from "../../state/stateService"; import {UISref} from "./uiSref"; import {PathNode} from "../../path/node"; @@ -9,7 +9,7 @@ import {TargetState} from "../../state/targetState"; import {TreeChanges} from "../../transition/interface"; import {State} from "../../state/stateObject"; import {anyTrueR, tail, unnestR} from "../../common/common"; -import {UIRouterGlobals, Globals} from "../../globals"; +import {Globals} from "../../globals"; import {Param} from "../../params/param"; import {PathFactory} from "../../path/pathFactory"; @@ -44,6 +44,7 @@ export class UISrefStatus { // current statuses of the state/params the uiSref directive is linking to @Output("uiSrefStatus") uiSrefStatus = new EventEmitter(false); + @ContentChild(UISref) sref: UISref; status: SrefStatus = { active: false, @@ -54,12 +55,11 @@ export class UISrefStatus { constructor(transitionService: TransitionService, private _globals: Globals, - private _stateService: StateService, - public sref: UISref) { + private _stateService: StateService) { this._deregisterHook = transitionService.onStart({}, $transition$ => this.processTransition($transition$)); } - ngOnInit() { + ngAfterContentInit() { let lastTrans = this._globals.transitionHistory.peekTail(); if (lastTrans != null) { this.processTransition(lastTrans);