Ionic Firebase NgFor仅支持绑定到诸如Arrays之类的Iterables

时间:2017-11-24 00:52:51

标签: angular firebase ionic-framework firebase-realtime-database

我有一个离子应用程序从Firebase获取数据。

{  
   "id":"-KysCBOOwaUnwX19RX0N",
   "nome":"Mais um teste de inclusao",
   "larguraPorta":"50",
   "alturaPorta":"20",
   "comprimento":"100",
   "telefone":"123456",
   "nmarquivo":"",
   "inicioOperacao":"00:00",
   "fimOperacao":"00:00",
   "temBwc":false,
   "temSalaVip":true,
   "temSalaAis":true,
   "temVigilancia":false,
   "temDormitorio":false,
   "temGpu":false,
   "temReboque":true,
   "temWifi":false,
   "aeroporto":{  
      "OACI":"SBPA",
      "UF":"RS",
      "municipio":"Porto Alegre",
      "nome":"Salgado Filho"
   },
   "imagens":{  
      "x1":{  
         "path":"http://static.progressivemediagroup.com/uploads/imagelibrary/nri/airport/clients/Jewers%20Doors/jewersld-2.jpg"
      },
      "x2":{  
         "path":"http://www.compasscommercial.com/wp-content/uploads/2017/01/1900-Airport-Way-FP1.jpg"
      }
   }
}

我想用ngFor将图像组显示在离子幻灯片中。但我遇到这样的问题:

  

NgFor仅支持绑定到诸如Arrays之类的Iterables。错误:不能   找到不同的支持对象' [object Object]'类型'对象'。   NgFor仅支持绑定到Iterables,例如Arrays

如何将我的firebase数据转换为可以在ngFor中使用的内容?

<ion-item *ngFor="let ima of items.hangar; let i = index" >
<ion-slides class="to-top" pager>
<ion-slide *ngFor="let x of ima.imagens">

我能够使用下面的变量创建幻灯片,而无需从firebase获取数据。

params: any = {};
           this.params.data = {
                    "items": [
                        {
                            "id": 1,
                            "title": "Nutrioso",
                            "subtitle": "Friday, August 07, 2017",                           
                            "imagens": [
                                {
                                    "id": 1,
                                    "image": "assets/images/gallery/nutrioso/1.jpg"
                                },
                                {
                                    "id": 2,
                                    "image": "assets/images/gallery/nutrioso/4.jpg"
                                }
                            ]
                        },
                        {
                            "id": 2,
                            "title": "Bluetown",
                            "subtitle": "Wednesday, July 05, 2017",                           
                            "imagens": [
                                {
                                    "id": 1,
                                    "image": "assets/images/gallery/bluetown/20.jpg"
                                },
                                {
                                    "id": 2,
                                    "image": "assets/images/gallery/bluetown/19.jpg"
                                }
                            ]
                        }
                    ]
                };

如何将firebase结构转换为这样的结构?

0 个答案:

没有答案