Check out this example code for a dynamic list
<ion-list no-lines [virtualScroll]="partnerArray">
<ion-item-sliding *virtualItem="let item; let i=index">
<ion-item (click)="view(i)">
<ion-avatar item-start>
<ion-img class="image" src="data:image/*;base64,{{item.imageUrl}}" style="height: 50px; width: 50px"></ion-img>
</ion-avatar>
<h2>{{item.name}}</h2>
<p>{{item.email}}</p>
</ion-item>
<ion-item-options>
<button ion-button color="danger" (click)="delete(i)">
Delete
</button>
</ion-item-options>
</ion-item-sliding>
And in the corresponding .ts
file
private partnerArray: Array<{
id: number
imageUrl: string,
name: string,
email: string
}> = []
this.odooRpc.searchRead(this.partner,
this.domain, this.fields, this.limit, this.offset,
this.sort).then((partner: any) => {
let json = JSON.parse(partners._body)["result"].records;
for (let i in json) {
this.partnerArray.push({
id: json[i].id,
imageUrl: json[i].image_small == false ? "N/A":json[i].image_small ,
name: json[i].name == false ? "N/A" : json[i].name,
email: json[i].email == false ? "N/A" : json[i].email
})
}
})
This snippet is tailored for an odoo server integration where records are fetched dynamically from the server.
Hope you find it useful!