ui-router breaks when minifying if the code isn't annotated properly. I have done this and most of my routes work, but this in particular does not:
var authRedirect = function(s) {
return ['$state', '$q', 'AuthService', function($state, $q, AuthService) {
var d = $q.defer();
var is_auth = AuthService.checkAuth();
if(!is_auth) {
d.reject();
$state.go(s);
} else
d.resolve();
return d.promise;
}];
}
// ...
.state('secret', {
url: '/secret',
controller: 'TestCtrl',
templatesUrl: '/test.html',
resolve: { authRedirect: authRedirect('other') }
})
.state('other', { .... } )
I'm passing in another state into my resolve function, which should redirect to that state if some condition isn't met. I use this resolve function in several other routes, so it's a handy way of keeping the ui-router code clean.
While the non-minified version is working fine, the minified version of this doesn't work (it does nothing). But it seems like I've annotated it properly since no errors were thrown. What could be wrong?
Please update the code with
.state('secret', {
url: '/secret',
controller: 'TestCtrl',
templatesUrl: '/test.html',
resolve: { authRedirect: ['authRedirect', function(authRedirect){ return authRedirect('other')}] }
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With