Angularfire2 5.0 Firebase数据在离子模板上显示查询



大家好,我在使用angularfire2 v5.0时遇到问题。我用了一段时间v4.0,现在我正在尝试用v5.0编程,并面临一些问题。

如何在ionic 3.0的标签/输入中显示Firebase实时数据?我以前订阅v4.0没有问题,现在我不明白了。当我使用我的代码时,我可以在console.log上显示,但不能在模板上显示。

import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AngularFireDatabase } from 'angularfire2/database';
import { Observable } from 'rxjs';
@Component({
selector: 'page-keyboard',
templateUrl: 'keyboard.html',
})
export class KeyboardPage {

userNachna: Text;
constructor(
public navCtrl: NavController, 
public navParams: NavParams,
public databaseFirebase: AngularFireDatabase,   
) {
}
loadDataFirebase(){
this.databaseFirebase.object('/test/').snapshotChanges()
.subscribe(action => {
console.log(action.type);                <-- WORKS
console.log(action.key)                  <-- WORKS
console.log(action.payload.val())        <-- WORKS
this.userNachna = action.payload.val();  <-- HERE THE ERROR
});
}

我的模板IONIC 3.0:

<ion-input type="text" #userNachna></ion-input>

模板可能看起来很像:

<ion-input type="text" value="{{action.payload.value}}></ion-input>

最新更新