Red Virus Red Virus - 4 years ago 216
AngularJS Question

Get object nested inside another object

How do I get

Photos
object? I have tried
{{ item.image.Photos[0].image }}
it doesn't work

enter image description here

TypeScript

listHotelPhotos( hotel_id ){
let loader = this.loadingCtrl.create({ content: 'Loading...' });
loader.present();
this.api.hotelPhotos( hotel_id ).subscribe( response => {
this.hotelImages = response.HotelImages;
this.Rooms = response.Rooms;
console.log( response.Rooms );
loader.dismiss();
});
}


HTML

<ion-grid class="select-room-types">
<ion-row *ngFor="let item of Rooms">
<ion-col width-100><img src="{{ item.image }}" /></ion-col>
<div class="caption">
<ion-grid class="select-room-card">
<ion-row>
<ion-col width-75>{{ item.name }}</ion-col>
<ion-col width-25>FJ ${{ item.rate }}</ion-col>
</ion-row>
</ion-grid>
</div>
</ion-row>
</ion-grid>

Answer Source

assuming Rooms is the array you posted an image of, it's just item.Photos[0].image

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download