I would do something like this:
$scope.logout = function(){ $ionicLoading.show({template:'Logging out....'}); $localstorage.set('loggin_state', ''); $timeout(function () { $ionicLoading.hide(); $ionicHistory.clearCache(); $ionicHistory.clearHistory(); $ionicHistory.nextViewOptions({ disableBack: true, historyRoot: true }); $state.go('login'); }, 30); };
I found out that adding a little delay allows $ionicHistory clear the cache.
$ionicHistory.nextViewOptions({ disableBack: true, historyRoot: true });
- disableBack . The following representation should forget about its reverse representation and set it to null.
- historyRoot . The following view should be the root view in its history stack.
source share