title: Ionic - Remove object from local storage
body: <p>I'm currently working with local storage for my Ionic app. I can add and get data from local storage, but when I try to delete a specific object, everything in my DB gets removed. And when I try to add a new object in my (now empty) DB I get the error message:
  "Runtime error - Cannot read property 'push' of undefined"</p>
  
  <p>The apps user scenario is that a user adds a favorite tv show to a favorites list, and from there be able to unfavorite if wanted to.</p>
  
  <p>Here's my code in my service which holds the functions for the localstorage:</p>
  
  <pre><code>export class FavoritesService{
  
    constructor(private storage: Storage){}
    public favoritesSeries: any = [];
  
    addSeriesToFavorites(serie: any)
    {
      this.favoritesSeries.push(serie);
      console.log('Add to');
      console.log(this.favoritesSeries);
      this.storage.set('FavSerie',this.favoritesSeries);
    }
  
    getFavoriteSeries(){
  
        this.favoritesSeries = [];
  
        this.storage.get('FavSerie').then((val) =&gt; {
          console.log(val);
          if (val){
            this.favoritesSeries = val;
          }});
    }
  
    removeFavoriteSeries(){
      this.storage.remove('FavSerie').then((val)=&gt;{
        this.favoritesSeries = val
        console.log('serie is removed');
      });
    }
  
    saveChanges(favoriteSeries: any) {
      this.favoritesSeries = favoriteSeries;
      this.storage.set('favoriteSeries', this.favoritesSeries);
    }
  }
  </code></pre>
  
  <p>My favorites page:</p>
  
  <pre><code>export class Favorites {
  
    series: {};
  
    constructor(public navCtrl: NavController,
                public navParams: NavParams,
                public seriesService: SeriesService,
                public alertCtrl: AlertController,
                public favoritesService: FavoritesService) {
    }
  
    ionViewDidLoad() {
      //presents the favorite series
      this.series = this.favoritesService.favoritesSeries;
      console.log(this.favoritesService.favoritesSeries);
      console.log(this.series);
    }
  
    onRemoveFromFavorites(FavSerie: any){
      const alert = this.alertCtrl.create({
        title: 'Remove From Favorites',
        subTitle: 'Are you sure?',
        message: 'Are you sure you want to remove from favorites?',
        buttons: [
  
          {
            text: 'Yes',
            handler: () =&gt; {
              console.log('OK');
              console.log(FavSerie);
              this.favoritesService.removeFavoriteSeries();
              console.log('efter service addToFavorite');
            }
          },
          {
            text: 'No',
            role: 'cancel',
            handler: () =&gt; {
              console.log('Cancel');
            }
          }
        ]
      });
      alert.present();
    }
  }
  </code></pre>