I’m making a simple hybrid app using which users can search for word meaning and bookmark words if they want and remove the bookmark as well.
I use Ionic2 storage for saving the words. I’m able to save value (bookmark words) but when I try to remove the bookmark, the process doesn’t happen.
here’s a screen shot of the stored data.
I am trying to remove a word from favorites array. But it ain’t happening.
home.ts
import { BabyRhymes } from './../../app/shared/babyRhymes.service';
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
@Component({
selector: 'page-word-definition',
templateUrl: 'home.html',
})
export class Home {
word:string;
constructor(public navCtrl: NavController,
public navParams: NavParams,
private babyrhymes: BabyRhymes) {
}
removeThisWord(word)
{
this.babyrhymes.unfavoriteWord(word);
}
}
From home.ts, I call the service which removes the word. Code for my service is as below:
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import 'rxjs/Rx';
import { Storage } from '@ionic/storage';
@Injectable()
export class BabyRhymes{
constructor(private storage: Storage){
}
unfavoriteWord(word)
{
this.storage.ready().then(
() => {
this.storage.remove(word);
});
}
}
I am new to ionic2. Can anybody point out the mistake I made?
Also, a side-question: By storing these values to Storage, am I really making use of SQLite or is it just indexedDb or WebSQL? Sometimes these values gets stored in IndexedDB and most of the time its in WEB SQL.
In app.module.ts, under imports, I gave the following:
IonicStorageModule.forRoot({
name: '__babydb',
driverOrder: ['indexeddb', 'sqlite', 'websql']
})
Thanks!