I have an angular app on a JSP page that has:
ng-init="role='<%=String.valueOf(session.getAttribute("role"))%>'"
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) {
$routeProvider
.when('somePath' {
...
})
.when('someOtherPath' {
...
})
.otherwise({
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?