Skip to content

Instantly share code, notes, and snippets.

@wishfoundry
Created January 15, 2014 23:58
Show Gist options
  • Save wishfoundry/8447220 to your computer and use it in GitHub Desktop.
Save wishfoundry/8447220 to your computer and use it in GitHub Desktop.
/*
$stateProvider.state('admin', {
url: '/admin',
data:{
title: 'Logout',
only: 'admin'
},
templateUrl: URL.toPartial('logout')
})
*/
app.run(function ($rootScope, $location) {
$rootScope.$on('$stateChangeStart', function (ev, to, toParams, from, fromParams) {
if(toParams.data.only) {
if($rootScope.currentUser.roles.indexOf(toParams.data.only) == -1)
//$state.go('home');
$location.path('/home')
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment