Update:
Below solution of mine is also working. I had a local storage
corruption or something like that.That was the reason for not working.
Question:
Can you tell me how to use promise
/ async
pipe and ngfor
? I have tried as shown below.But it is not working.
html
<ion-item *ngFor="let c of contacts | async">
<ion-label fixed>c.name</ion-label>
</ion-item>
ts
contacts: Promise<Contact[]>;
constructor() {
this.getContacts()
}
getContacts() {
this.contacts = this.storage.get('contacts').then((val: Contact[]) => {
console.log('log', val);
return val;
});
}
try this on your .ts
file:
getContacts() {
this.contacts = this.storage.get('contacts');
}
this way in your html the async pipe will subscribe to the promise
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.