Having some trouble getting $state.go() function to work. The $on('$stateChangeStart'...); is functioning properly, and I can see the console message when trying to access a protected state without permission. However, the $state.go('toState.name,toParams'); does not seem to be working correctly. Does anyone have any suggestions on how to resolve this issue?
Any assistance would be greatly appreciated, thank you.
app.run(function ($rootScope,$state) {
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
var requireLogin = toState.data.requireLogin;
$rootScope.currentUser = true;
if ($rootScope.currentUser === true && requireLogin === true) {
console.log(requireLogin);
console.log($rootScope.currentUser);
event.preventDefault();
$state.go(toState.name, toParams);
}
else {
console.log(requireLogin);
console.log($rootScope.currentUser);
$state.go('login.signin');
}
});
});