I have an angular app on a JSP page that has:


So the body tag will look like this when the JSP pulls the role attribute from the session:

<body ng-app="appName" ng-init="role='roleName'">

I want to access this role variable in the $routeProvider.

I tried doing so by passing $scope to the app.config function as such:

app.config(['$routeProvider', '$scope',
    function ($routeProvider, $scope) {
        .when('somePath' {
        .when('someOtherPath' {
            redirectTo: $scope.role == 'goodRole' ? 'somePath' : 'someOtherPath'

However, it appears that you cannot pass in the $scope that way.

Is there a way to access a scope variable in this fashion, or is there another way to accomplish this?