Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic - there is a way to delete the cache in controller method?

Tags:

caching

ionic

I know how to make the cache cleared for view :

  .state('app.list', {
    cache : false,
    url: "/lists/:listId",
    views: {
      'menuContent': {
        templateUrl: "templates/listDashboard.html",
        controller: 'listDashboardCtrl'
      }
    }
  })

, but I need something else - delete all the cache for the app in controller method. how to do it?

like image 217
GO VEGAN Avatar asked Apr 12 '15 18:04

GO VEGAN


1 Answers

I found a solution, Wrap the clearCache and ClearHistory in a $timeout. Something Like this.

$scope.logout = function(){
      $location.path('/signin')
      $timeout(function () {
          $ionicHistory.clearCache();
          $ionicHistory.clearHistory();
          $log.debug('clearing cache')
      },300) 
}

Edit:Changed Timeout seconds

like image 145
Karan Kumar Avatar answered Sep 17 '22 23:09

Karan Kumar