2016-08-31 38 views
0

在我的項目簽出後,我重定向用戶去'登錄'狀態。但是,如果我試圖再次登錄而不刷新頁面,則登錄不會發生。一旦我刷新頁面,它就會工作。所以請幫助我如何解決這個問題。下面我分享代碼。如何在成功註銷angularJs後重新加載登錄頁面?

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> 

我打電話的logoutController在signout.html頁

回答

1

3個選項,而不是$state.go('login');

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

OR

window.location.replace('/login') 

OR

$state.go('login'); 
window.location.reload() 
+0

我必須在logoutController編寫上面的代碼沒有?? – Kishan

+1

謝謝,第三個人爲我工作。 – Kishan

1

添加reload: true財產。

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

它不是爲我工作。它獲得註銷,但如果我想再次登錄其不登錄。 – Kishan

相關問題