Skip to content

Commit

Permalink
feat(uiView): add getter for state which is filling the uiview
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Nov 5, 2017
1 parent 3d532b6 commit e7cb5f1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/directives/uiView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ export class UIView {
this._parent = parent;
}

/**
* @returns the UI-Router `state` that is filling this uiView, or `undefined`.
*/
public get state(): StateDeclaration {
return parse("_uiViewData.config.viewDecl.$context.self")(this);
}

ngOnInit() {
const router = this.router;
const parentFqn = this._parent.fqn;
Expand Down Expand Up @@ -149,7 +156,7 @@ export class UIView {
const uiCanExitFn: TransitionHookFn = instance && instance.uiCanExit;

if (isFunction(uiCanExitFn)) {
const state: StateDeclaration = parse("_uiViewData.config.viewDecl.$context.self")(this);
const state: StateDeclaration = this.state;

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

0 comments on commit e7cb5f1

Please sign in to comment.