KISHAN PATI KISHAN PATI - 3 months ago 29
AngularJS Question

How to reload login page after successfully logout in angularJs?

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

Answer

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()
Comments