Is it possible to clear the view cache in Ionic?

前端 未结 5 1104
攒了一身酷
攒了一身酷 2020-12-01 02:48

I\'m currently working on a Angular/Ionic/Cordova project and we\'ve recently upgraded to the latest Ionic beta. From the version the project was using before, this introduc

5条回答
  •  孤城傲影
    2020-12-01 03:34

    I stumbled across a similar scenario where logging in with another user was showing me stale/cached view. You can do cache: false at the state definition level but that entirely disables cache for that state in your app.

    What you can rather do is clear all the cached view and history when user enters the signin/login state of your application (as you said). Seems ideal.

    // code inside your signin controller
    
    $scope.$on("$ionicView.enter", function () {
       $ionicHistory.clearCache();
       $ionicHistory.clearHistory();
    });
    

提交回复
热议问题