1

In my project after signing out i redirecting the user to go 'login' state. But if am trying to login again without refreshing the page then login is not happening. It works once i refresh the page. So please help me how to resolve this. Below am sharing the code.

logoutController.js

angular.module("adminsuite").controller("headerController",['AuthenticationService','$state','$rootScope','$cookieStore','$scope',function(AuthenticationService,$state,$rootScope,$cookieStore,$scope){
  $scope.header = $state.current.name;
  $rootScope.global = {
        search: '',
        newsurvey: false
     };
$scope.logout = function(){
                //$scope.dataLoading = true;
                AuthenticationService.ClearCredentials();
                $state.go('login');
                console.log($cookieStore.get('globals'));
                //$state.go('login');
            };
}]);

signout.html

<a ng-click='logout()'><p class="small-font"><img src = "images/signout.png" class="thumbpreImg" alt = "logoutImg"> Log out</p></a>

I am calling the logoutController in the signout.html page

3 Answers 3

4

3 options instead of $state.go('login');

$state.go('login', null, {reload: true});

OR

window.location.replace('/login')

OR

 $state.go('login');
 window.location.reload()
Sign up to request clarification or add additional context in comments.

1 Comment

I have to write this above code in the logoutController no ??
1

Add reload: true property.

$scope.logout = function(){
    //$scope.dataLoading = true;
    AuthenticationService.ClearCredentials();
    $state.go('login', null, {reload: true});
    };
}]);

1 Comment

it is not working for me. its getting logout but if i want to login again its not loging in.
0

Use Angular service to Reload your views:

  • use $route.reload() to reload the current view (route).
  • use $location.path(newPath) for navigating to other views.

Docs: (For Route) https://docs.angularjs.org/api/ngRoute/service/$route

Docs: (For Location) https://docs.angularjs.org/api/ng/service/$location

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.