Skip to content

Instantly share code, notes, and snippets.

@wojciak
Created July 2, 2014 13:50
Show Gist options
  • Save wojciak/a60427ec3aa919498862 to your computer and use it in GitHub Desktop.
Save wojciak/a60427ec3aa919498862 to your computer and use it in GitHub Desktop.
UI router seamless redirects
// Feature routing - here we can create seamless redirects based on features
app.run(/* ngInject */ function ($state, $rootScope) { // ngAnnotate
$rootScope.$on('$stateChangeStart', function (e, toState) {
// 1. Dashboard disabled - when we want to go to it ("root" state) we should get a project list instead
if (toState.name === 'root') {
if (!features.active('dashboard')) { // an example feature checker
$state.go('root.project.list');
e.preventDefault();
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment