Created
July 2, 2014 13:50
-
-
Save wojciak/a60427ec3aa919498862 to your computer and use it in GitHub Desktop.
UI router seamless redirects
This file contains 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
// 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