我试图从Typescript中使用AngularFire2从Firebase读取数据。我的代码在检索数据列表时与异步管道协同工作,但在获取对象时,我无法访问这些内容。上火力地堡AngularFire2检索对象数据不工作,但列表数据确实
数据结构:(myapp.firebaseio.com/LeagueStandings)
子集的代码:
import { Component } from '@angular/core';
import { AngularFireDatabase, FirebaseObjectObservable } from 'angularfire2/database';
Standings: FirebaseObjectObservable<any[]>;
constructor(public FirebaseData:AngularFireDatabase) {
this.Standings = FirebaseData.object('/LeagueStandings');
// Added the following to see the debug
this.Standings.subscribe(data => {
console.log(data);
});
}
HTML采样位:
<ion-col><ion-badge color="secondary">{{Standings.Wins | async }}</ion-badge></ion-col>
的问题是数据从不显示。然而,使用FirebaseData.list的阵列数据(例如单个游戏统计数据)的相同类型的确行得通。我不知道如何轻松提取要显示的页面的数据结构。
添加控制台转储确实显示从Firebase返回的数据,但我的home.html没有更新。
你在哪里设置'LeagueInfo'? – theblindprophet
对不起,这是一个从编辑代码到小样本复制的错字。我更新了HTML,因为它应该引用排名。 –
我仍在调查它,但你有没有尝试过其他语法?就像那个'排行榜'''赢'''? (远射.. :)) – nisanarz