I have a modular structure for my application. I have many configuration files with a route definition in them. I am trying to use resolver to authenticate the user or not before moving them to the next kind of route.
right now I can reuse the function in the config as a solution method ie
function resolverFunc(Auth, $state){
if(!Auth.isLoggedIn()){
$state.go('login');
}
}
$stateProvider.state('state1', {
url: "/myurl",
resolver:{
loggedIn: resolverFunc
}
}
)
.state('state2',{
url: '/url2',
resolver:{
loggedIn: resolverFunc
}
})
The problem is what I have to define resolverfuncin each module. Because each module has its own module.config(), where routes are defined for this module.
Is there a simpler solution. I do not like to rewrite this function in each configuration file for all modules with routes