我正在開發使用離子2,Angularfire 2和火力地堡移動應用檢索收集,但我堅持,這是我的火力地堡數據結構:離子2 Angularfire 2從火力
我需要從carrito
創建一個列表,但同時我需要獲取precio
字段並將其鏈接到另一個集合 - precios
,並獲取關鍵字值(如上圖所示),相關字段(opcion & PRECIO)。
代碼:list.ts
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {AngularFire, FirebaseListObservable} from 'angularfire2';
@Component({
selector: 'page-lista',
templateUrl: 'lista.html',
})
export class Lista {
public restaName:any;
serviceData: string;
carrito: FirebaseListObservable<any>;
precios: FirebaseListObservable<any>;
constructor(public navCtrl: NavController, public navParams:
NavParams, af: AngularFire, private shareService: ShareService) {
this.serviceData = shareService.getRestaName();
this.restaName = this.serviceData
this.carrito = af.database.list('/carrito', {
query: {
orderByChild: 'restaname',
equalTo: this.restaName
}
});
this.precios = af.database.list('/precios', {
query: {
orderByKey: true,
equalTo: this.precio ???? ---> HERE BEGIN MY DOUBTS
}
});
}
這裏是lista.html
<ion-content padding>
<ion-list>
<ion-item *ngFor="let item of carrito | async ">
<p> {{item.prodname}} - {{item.cantidad}}</p>
</ion-item>
<ion-item *ngFor="let precio of precios | async "> ??? HOW CAN I GET THE FIELDS precio and opcion
<p>${{precio.precio}}</p>
</ion-item>
</ion-list>
</ion-content>
任何提示或意見的部分將不勝感激!
提供代碼,請。 – theblindprophet