I have a service that checks if the current user has access to a route. I would like this service to be called as part of the permission so that the view never loads if the user should not have access. However, in the resolution function, the $ state dependency does not yet contain the actual state of the router.
.state('home', {
url: '/home',
templateUrl: 'app/home.html',
controller: 'HomeController',
controllerAs: 'main',
resolve: {
allowed: function(auth, $state) {
return auth.isAllowed($state.current.name);
}
},
})
... however $state.current.nameempty at the point at which it is used. How to pass the name of the state (ie "Home")?
source
share