ユーザーの役割に基づいて角度アプリケーションにルートを登録したいのですが、次のようなことができますか?
angular.module('myModule', [])
.config(function($routeProvider, $http){
$routeProvider.when('/home',{
templateUrl: '/home.html',
controller: 'HomeCtrl'
});
$http.get('/user')
.success(function(user){
if (user.admin){
$routeProvider.when('/dashboard, {
templateUrl: '/dashboard.html',
controller: 'DashboardCtrl'
});
}
});
});
しかしconfig
、サービスを利用できない方法では$http
、どうすればそれを達成できますか?