目前我可以将数据发布到firebase,但我无法获取数据并将其显示在我的离子3应用程序中。这是我的shoes.ts文件:
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { AngularFireDatabase } from "angularfire2/database";
import { FirebaseListObservable } from 'angularfire2/database';
@Component({
selector: 'page-shoes',
templateUrl: 'shoes.html',
})
export class ShoesPage {
shoppingItems: FirebaseListObservable<any[]>;
newItem = '';
getShoppingItems() {
return this.afDB.list('/shoppingItems/');
}
constructor(public navCtrl: NavController, public navParams: NavParams,
public afDB: AngularFireDatabase){
this.addItem("awesomeStuff");
this.getShoppingItems();
alert(this.shoppingItems);
}
ionViewDidLoad() {
console.log('ionViewDidLoad ShoesPage');
}
addItem(name) {
this.afDB.list('/shoppingItems/').push(name);
}
removeItem(id) {
this.afDB.list('/shoppingItems/').remove(id);
}
}
这是我的shoes.html文件的一部分:
<ion-list>
<ion-item class="text" *ngFor="let item of shoppingItems | async">
{{item.$value}}
</ion-item>
</ion-list>
我是如何能够显示firebase数据的?目前我正在收到:[object Object],当我提醒shoppingList时。