Last active
November 4, 2016 15:10
-
-
Save jannickfahlbusch/f4f2c3f411afea7c14eb to your computer and use it in GitHub Desktop.
This snippet goes up the UI-Router-Tree and transitions to the first state, wich is not abstract. https://jf-projects.de/post/UI-Router:-Access-Parent-but-not-abstract-state/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| goToParentState: function() { | |
| var states = $state.current.name.split('.'); | |
| for (var i = states.length - 1; i > 0; i--) { | |
| var stateName = ''; | |
| for (var j = 0; j < i; j++) { | |
| stateName += states[j] + (((j + 1) < i) ? '.' : ''); | |
| } | |
| if (!$state.get(stateName).abstract) { | |
| $state.go(stateName); | |
| break; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment