angular ui router - AngularJS get next $state -


hey guys wrote code front end check (i checked in server side). see if user logged or not depending in "state" or path in case, because using $location first, moved ui.router. suggestions of how make code work ui.router:

app.run(function($rootscope, $state, checklogin, user) {   $rootscope.$on("$statechangestart", function(event, next, current) {     checklogin.check(function(response) {       if (response) {         var nexturl = next.$$route.orginalpath          if (nexturl == 'login' || nexturl == '/') {           $state.target('panel')         }          $rootscope.islogged = true;       } else {         $rootscope.islogged = false;         $state.target('login')       }     });   }); }); 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -