I am using angular-permission and try to redirect users according to their roles.
I am trying to make something like this, but am not able to inject rootScope inside app.config to get the user:
redirectTo: function(){
if($rootScope.isAdmin){
}
else{
}
return 'login';
}
and here's the config section inside my app.js file
.config(['$stateProvider', '$locationProvider', '$datepickerProvider', '$timepickerProvider', 'RestangularProvider', '$httpProvider', '$scrollspyProvider', function ($stateProvider, $locationProvider, $datepickerProvider, $timepickerProvider, Restangular, $httpProvider, $scrollspyProvider) {
$stateProvider
.state('test', {
url: '/test',
templateUrl: "/test.html",
data: {
title: 'test',
pageTitle: 'test',
access: 'authenticated',
permissions: {
only: ['admin'],
redirectTo: function(){
//////////////////////////////////
}
}
}
})
}])
Is there a different way to do this ?