Skip to content

Commit e7cb5f1

Browse files
feat(uiView): add getter for state which is filling the uiview
1 parent 3d532b6 commit e7cb5f1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/directives/uiView.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ export class UIView {
117117
this._parent = parent;
118118
}
119119

120+
/**
121+
* @returns the UI-Router `state` that is filling this uiView, or `undefined`.
122+
*/
123+
public get state(): StateDeclaration {
124+
return parse("_uiViewData.config.viewDecl.$context.self")(this);
125+
}
126+
120127
ngOnInit() {
121128
const router = this.router;
122129
const parentFqn = this._parent.fqn;
@@ -149,7 +156,7 @@ export class UIView {
149156
const uiCanExitFn: TransitionHookFn = instance && instance.uiCanExit;
150157

151158
if (isFunction(uiCanExitFn)) {
152-
const state: StateDeclaration = parse("_uiViewData.config.viewDecl.$context.self")(this);
159+
const state: StateDeclaration = this.state;
153160

154161
if (trans.exiting().indexOf(state) !== -1) {
155162
trans.onStart({}, function() {

0 commit comments

Comments
 (0)