我想使用angularfire2 5.0.0-rc.2將Firebase中的對象列表顯示到Ionic視圖。從angularfire2檢索嵌套的數據列表5.0.0-rc.2
這是我從火力地堡
對象名單這是從服務的方法,用於檢索有關的所有餐廳的數據
getRestaurants() {
this.restaurants = this.af.list('/Restaurants')
return this.restaurants;
}
這是我接受服務數據的組件
export class RestaurantsPage {
restaurants: Observable<any[]>;
constructor(public navCtrl: NavController, public af: AngularFireDatabase, public dataservice: handleDataService) {
this.dataservice.getUserEmail().subscribe(res => {
this.restaurants = this.dataservice.getRestaurants().valueChanges();
})
// this.items.subscribe(res => console.log(res[0].$key));
}
這是我要顯示我的數據
<ion-content class="card-background-page">
<ion-list>
<ion-item *ngFor="let restaurant of restaurants | async">
<ion-thumbnail item-start>
<img src="img/thumbnail-totoro.png">
</ion-thumbnail>
<h2>{{restaurant.Name}}</h2>
<h3>{{restaurant.Description}}</h3>
<button ion-button clear item-end (click)="gotoPage(restaurant)">View</button>
</ion-item>
</ion-list>
</ion-content>
HTML頁中,我知道在服務方法我沒有做什麼,只是返回的值越來越形式火力地堡API 。我想知道如何遍歷s @ g,com中的密鑰,並將我的HTML頁面中每個鍵內的數據顯示爲一個列表。我也嘗試過使用map運算符,但我在angularfire2 5.0.0-rc.2中找不到更好的解決方案。
[請勿將您的代碼發佈爲圖片。](// meta.stackoverflow.com/q/285551) –