Closed HASSANDL closed 6 years ago
Resolve is intended to manage async data fetching. It wasn't intended to be used for redirect. For redirects, we generally use a transition hook. The transition hook has access to all the resolved data via the transition.injector()
.
If you want to redirect from a resolve, I suppose you could inject the current transition into the resolve, cancel the transition, and start a new one. It would look something like this:
resolve: ['$transition$', '$myService', function($transition$, $myService) {
if ($myService.something) {
$transition$.cancel();
$transition$.router.stateService.go('otherplace');
}
}]
How redirect in resolve without use $timeout? (version 1.0.18)