I have checks to see weather a user has access to pages which is executed inside $stateChangeStart
Here it is
$rootScope.$on('$stateChangeStart', function (event, toState) {
if ($rootScope.accessRights.length > 0) {
if (toState.data.accessControlled == true) {
var userHasAccess = false;
for (var i = 0; i < $rootScope.accessControlledPages.length; i++) {
if (toState.name == $rootScope.accessControlledPages[i].page) {
userHasAccess = true;
break;
}
}
//If user has access do nada, else redirect them to 404 page or page to TBD
if (!userHasAccess) {
event.preventDefault();
$state.go('Errors');
}
}
}
else
{
processPageAccess();
$state.go(toState.name);
}
});
The problem I have is that $state.go('Errors');
Does nothing, I just stay on the page that I was on when I attempted to navigate to the access controlled page. Is there something I'm not doing