如何从 SQlite 数据库加载所有数据? (离子 3,Angular 5,科尔多瓦)
How can I load all data from SQlite database? (Ionic 3, Angular 5, Cordova)
如何一次加载存储在 sqlite 存储中的所有数据?
我有几个具有不同键和 ID 值的数据对象。
我想使用 *ngFor 指令将它们全部加载到一个列表中。
<div *ngFor="let item of items">
<h1>{{ item.name }}</h1>
<p> {{ item.about }} </p>
</div>
这是我的家庭 ts 文件:
ionViewDidLoad() {
this.storage.get(item);
}
这段代码显然不会起作用。我知道如何使用此 get() 方法获取单个数据对象,但我不知道如何一次加载所有内容。
请帮忙。
谢谢,
IonicNative Storage 包装器公开了一个 forEach
方法。
此方法将return所有键:值对
this.storage.forEach((value, key, iterationNumber) => {
// here you can do whatever you want to do with all the data.
});
在此处阅读更多相关信息:Ionic Storage: forEach
如何一次加载存储在 sqlite 存储中的所有数据?
我有几个具有不同键和 ID 值的数据对象。
我想使用 *ngFor 指令将它们全部加载到一个列表中。
<div *ngFor="let item of items">
<h1>{{ item.name }}</h1>
<p> {{ item.about }} </p>
</div>
这是我的家庭 ts 文件:
ionViewDidLoad() {
this.storage.get(item);
}
这段代码显然不会起作用。我知道如何使用此 get() 方法获取单个数据对象,但我不知道如何一次加载所有内容。
请帮忙。
谢谢,
IonicNative Storage 包装器公开了一个 forEach
方法。
此方法将return所有键:值对
this.storage.forEach((value, key, iterationNumber) => {
// here you can do whatever you want to do with all the data.
});
在此处阅读更多相关信息:Ionic Storage: forEach