Reputation: 953
I have the following Array.
This is my home.ts
initializeItems() {
this.items = [
{nome:'Abaeté', rua:'text' ,
imagem:"assets/img/4Wj6RBrjQPGiTMhV6T9W_Abaete.JPG"}
];
}
And here I have the code home.html
where is my ion-list
<ion-list>
<ion-item *ngFor="let item of items">
<ion-thumbnail item-left>
<img src="assets/img/4Wj6RBrjQPGiTMhV6T9W_Abaete.JPG" />
</ion-thumbnail>
{{ item }}
</ion-item>
</ion-list>
But on my ion-list the name and image are not going!
Here's an example image
Upvotes: 0
Views: 3772
Reputation: 9227
So you need to do the "mapping" correctly here:
<ion-list>
<ion-item *ngFor="let item of items">
<ion-thumbnail item-left>
// use property binding like this, question mark in case the item is not available:
<img [src]="item?.imagem"/>
</ion-thumbnail>
{{ item?.nome }}
</ion-item>
</ion-list>
The way it work is that with ngFor directive you "iterate" over array like structures (array in your case):
[
{ // this will be "item", which properties you access using item.property
nome:'Abaeté',
rua:'text',
imagem:"assets/img/4Wj6RBrjQPGiTMhV6T9W_Abaete.JPG"
}
]
Upvotes: 1