Tutorialsplane

Ionic clear localstorage data


Ionic clear localstorage data : if you want to clear local storage data in ionic framework you can use the clear method to clear the cache, localstorage and history. Here in this tutorial we are going to explain how you can clear local storage data in ionic framework.


Ionic clear localstorage data

If you want to clear localstorage use the below method-

Ionic clear localstorage data:

 $window.localStorage.clear();
 $ionicHistory.clearCache();
 $ionicHistory.clearHistory();

Or you can create a function and call it when you want to clear local storage.

Here a function in your controller call this to clear data in ionic –

Ionic clear localstorage data: Example

 $scope.clearLocalStorage = function(){
 $window.localStorage.clear();
 $ionicHistory.clearCache();
 $ionicHistory.clearHistory();
 };

If you call the above method in your application it will clear all local storage data.

Ionic FAQ