JSP ページに次のような角度のあるアプリがあります。
ng-init="role='<%=String.valueOf(session.getAttribute("role"))%>'"
したがって、JSP がセッションから role 属性を取得すると、body タグは次のようになります。
<body ng-app="appName" ng-init="role='roleName'">
roleでこの変数にアクセスしたい$routeProvider。
$scope私はそのようにapp.config関数に渡すことでそうしようとしました:
app.config(['$routeProvider', '$scope',
function ($routeProvider, $scope) {
$routeProvider
.when('somePath' {
...
})
.when('someOtherPath' {
...
})
.otherwise({
redirectTo: $scope.role == 'goodRole' ? 'somePath' : 'someOtherPath'
});
}]);
しかし、その通りには通れない$scopeようです。
この方法でスコープ変数にアクセスする方法はありますか、またはこれを達成する別の方法はありますか?