Skip to content

Instantly share code, notes, and snippets.

@edin-m
Created March 13, 2015 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edin-m/f67ebb82b4c025a92d21 to your computer and use it in GitHub Desktop.
Save edin-m/f67ebb82b4c025a92d21 to your computer and use it in GitHub Desktop.
Redirection with angular ui router states.
// this is needed when there are multiple hierarchy states
// articles
// articles.view
// articles.add
// articles.config
// articles.config.type1
// articles.config.type2
angular.module('articles')
.run([
'$rootScope',
'$state',
function($rootScope, $state) {
var redirect = {
'articles': '.view',
'articles.config': 'articles.view'
};
$rootScope.$on('$stateChangeSuccess', function(event, toState) {
if(redirect[toState.name]) {
$state.go(redirect[toState.name]);
}
});
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment