获取嵌套在另一个对象中的对象

时间:2017-02-04 23:53:10

标签: javascript angularjs ionic-framework

如何获取Photos对象?我试过{{ item.image.Photos[0].image }}它不起作用

enter image description here

打字稿

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>

1 个答案:

答案 0 :(得分:1)

假设Rooms是您发布图像的数组,它只是item.Photos[0].image