I am trying to add a resolver function for each state in my application in order to wait for the application loading process to complete. I already have the following code:
angular.forEach($state.get(), function(state) {
state.resolve = state.resolve || {};
state.resolve.session = function() {
return SessionResolver.handle(state);
}
});
SessionResolver is a service in which a function handle(state)returns a promise that is resolved after the download process completes.
This works fine if no state is defined without an existing object resolve. For example, the following state will be blocked until the promise SessionResolver.handle is defined:
$stateProvider.state('dashboard', {
url: "/",
templateUrl: "dashboard.html",
controller: "DashboardCtrl",
resolve: {}
});
But if the permission object is not set, the state is not blocked:
$stateProvider.state('dashboard', {
url: "/",
templateUrl: "dashboard.html",
controller: "DashboardCtrl",
});
resolve , SessionResolver.handle , .
, , ?