Redirect state in angularjs Redirect state in angularjs angularjs angularjs

Redirect state in angularjs


Ooooh you're so close. I rearranged some of your code and arrived at this:

app.run(function($rootScope, $grabhutAccountService) {   $rootScope.$on('$stateChangeSuccess', function (evt, toState) {     if (toState.name === 'nv.logout') {       $grabhutAccountService.logoutUser();       $state.go('account.main');     }     });});

The next major version of UI-Router will have much improved hooks for doing this sort of thing.