angularjs - $routeprovider resolve Function Causing Infinite Loop -


i using resolve function in route provider re-route different types of users different home screens when go / page. code works on first page load. resolve looking @ user status , taking them correct screen. however, when re-load / page, infinite loop. in console see enter else statement , re-enter controller. browser keeps loading my controller until browser crashes. here's code

 myapp.config(function($routeprovider){   $routeprovider.when('/', {     templateurl: "views/index.html",     resolve:{         "check":function($location){             if(vm.status === 0){               console.log('in if statment');               $location.path('/create-new-user');               return 200;             }             else if(vm.status === 2){               console.log('in else if statment');               $location.path('/devices');               return 200;             }             else{               console.log('in else statement');                 $location.path('/login');    //redirect user home.                 alert("you don't have access here");                 return 200;             }         }     }   }).when('/create-new-user', {     templateurl: 'views/partials/createnewuser.html'   }).when('/devices', {     templateurl: 'views/partials/devices.html'   }).when('/login', {     templateurl: 'views/partials/loginpartial.html'   }).when('/change-password', {     templateurl: 'views/partials/changepassword.html'   }).when('/edit-profile', {     templateurl: 'views/partials/editprofile.html'   }).when('/contacts', {     templateurl: 'views/partials/contacts.html'   }).when('/manage-users', {     templateurl: 'views/partials/manageusers.html'   }).otherwise({ redirectto: '/'}); }); //end config 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -