How can I load all data stored in sqlite storage at a time?
I have several data objects with different keys and id values.
I want to load them all on a single list using *ngFor directive.
<div *ngFor="let item of items">
<h1>{{ item.name }}</h1>
<p> {{ item.about }} </p>
</div>
and here's my home ts file for that:
ionViewDidLoad() {
this.storage.get(item);
}
this code will not work obviously. I know how to get a single data object using this this get() method but I don't know how to load everything at a time.
Please help.
Thanks,
IonicNative Storage wrapper exposes a forEach
method.
This method will return all the key: value pairs
this.storage.forEach((value, key, iterationNumber) => {
// here you can do whatever you want to do with all the data.
});
Read more about it here: Ionic Storage: forEach