this has been posted many times but I'm still not having luck with this:
$rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) {
if (error && !error.authenticated) {
$location.path('/login');
console.log('new path: ' + $location.path());
}
});
My app will in fact not go to /login, yet the console.log will return a value of /login. I've tried the $apply trick without luck mentioned in other threads but this is a very simple app at this point, no third party integrations where angular needs some additional help via $apply. Is there a variant to $location.path() needed when used within the context of $rootScope, or listening for $stateChangeError?
I'm sure this is something simple and I'm just not seeing it.