Delete all local storage

hey guys
if i want to create a button that delete all local storage from all page in my app i use ionic 2 typescript :slight_smile:

Regards

According to the ionic2 API, the method you need is clear().

http://ionicframework.com/docs/v2/api/platform/storage/LocalStorage/

So your code might look like this:

import {Component} from '@angular/core';
import {Storage, LocalStorage} from 'ionic-angular';
@Component({
  template: `<ion-content></ion-content>`
});
export class MyClass{
 constructor(){
   this.local = new Storage(LocalStorage);
   this.local.set('didTutorial', 'true');
 }

function resetLocalStorage(){
  this.local.clear();
}

}

hi @Gatewayapp

You need to call the clear() method of your local storage.
e.g localStorage.clear();
OR you can use $localStorage.$reset();
it will delete all your data from localStorage.

1 Like