I might have some kind of missunderstanding. Im using angular ui router and i have the next issue:
I have the next State provider:
angular
.module(\'Main
So i've made it work the different way, ive used $stateChangeStart and now my run function looks like this:
angular
.module('MainApp')
.run(['$rootScope', '$state', '$cookieStore', 'principal',
function ($rootScope, $state, $cookieStore, principal) {
var cookies = $cookieStore.get('user');
if (cookies) {
principal.Authenticate(cookies.split(' ')[0], cookies.split(' ')[1]);
}
$rootScope.$on('$stateChangeStart',
function (event, toState) {
if ((toState.name === "register") && (principal.isAuthenticated)) {
event.preventDefault();
$state.go('main', { userId: principal.identity().userId });
}
});
}
]);
But i still dont know why $state.go() didnt work...