reload page in angular js after logout

Issue

Hi guys am a beginner in mean stack development I have tried to refresh the page after logout.I have tried location.reload(); but it doesn’t work tell me the possible code for page reload in this scenario

$rootScope.$on('$routeChangeStart', function (event) {
    var storage = userService.isLoggedIn();
    console.log(storage);

    if (!storage) {
        console.log('DENY');
        $rootScope.adminlogin = "adminlogin";
        console.log($rootScope.adminlogin);

        $location.path('/login');
        $route.reload();      
       // $state.go('/login', null, {reload: true});
    }
    else {
        console.log('ALLOW');
        $rootScope.admindashboard = "admindashboard";
         var path = $location.path();
          console.log(path);
          console.log(storage);
         if(path == '/login'){
            $location.path('/');
         }


    }
});

Solution

All you need to do is this little line of Vanilia JS:
document.location.href=document.location.href

EDIT: why is this getting downvoted?

Answered By – Johnsons Gaming

Answer Checked By – Katrina (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.