Skip to content

Instantly share code, notes, and snippets.

@jannickfahlbusch
Last active November 4, 2016 15:10
Show Gist options
  • Select an option

  • Save jannickfahlbusch/f4f2c3f411afea7c14eb to your computer and use it in GitHub Desktop.

Select an option

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/
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