显示从 AngularFireDatabase 列表返回的值?
Displaying values returned from AngularFireDatabase list?
我正在尝试在我的 Ionic 3 应用程序中查询我的 Firebase 数据库中的一些数据。我试图遵循 this tutorial 中的语法,但我将 运行 保留为错误:
ERROR TypeError: queryFn is not a function
这是我使用的代码:
this.games = this.afDatabase.list('/games/', {
query: {
orderByChild: user.uid
}
});
我的进口商品:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireFunctions } from 'angularfire2/functions'
import { AuthProvider } from '../../providers/auth/auth';
import { AngularFireDatabase } from 'angularfire2/database';
import { Facebook } from '@ionic-native/facebook';
是什么导致了该错误?
编辑
看来我尝试遵循的教程已经过时了。
我(有点)让它与这段代码一起工作。
this.afDatabase.list<Game>('/games/', ref => ref.orderByChild(user.uid)).valueChanges().subscribe(data => console.log(data));
但它会导致另一个错误:
Uncaught TypeError: Object(...) is not a function
如何在我的模板中显示返回的可观察对象?我试过像上面那样订阅,我也试过直接在模板中这样做:
this.games = this.afDatabase.list<Game>('/games/', ref => ref.orderByChild(user.uid)).valueChanges();
然后在模板中:
*ngFor="let game of games | async"
导致错误:
Uncaught TypeError: Object(...) is not a function
this.games 是可观察的?
gameCol: AngularFirestoreCollection;
games: Observable<Games[]>;
gameArray: Games[];
getAllGames() {
this.gameCol= this.db.collection('games');
return this.gameCol.valueChanges();
}
this.games.getAllGames();
this.games.subscribe(game => {
this.gameArray = game;
});
在HTML
<select class="form-control">
<option [value]="0">Select</option>
<option *ngFor="let game of games">
{{game.something}}
</option>
</select>
我归因于另一个问题的关于我的另一个问题的解决方案解决了这个问题。
需要将 rxjs 从版本 5 更新到版本 6。
我正在尝试在我的 Ionic 3 应用程序中查询我的 Firebase 数据库中的一些数据。我试图遵循 this tutorial 中的语法,但我将 运行 保留为错误:
ERROR TypeError: queryFn is not a function
这是我使用的代码:
this.games = this.afDatabase.list('/games/', {
query: {
orderByChild: user.uid
}
});
我的进口商品:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireFunctions } from 'angularfire2/functions'
import { AuthProvider } from '../../providers/auth/auth';
import { AngularFireDatabase } from 'angularfire2/database';
import { Facebook } from '@ionic-native/facebook';
是什么导致了该错误?
编辑
看来我尝试遵循的教程已经过时了。 我(有点)让它与这段代码一起工作。
this.afDatabase.list<Game>('/games/', ref => ref.orderByChild(user.uid)).valueChanges().subscribe(data => console.log(data));
但它会导致另一个错误:
Uncaught TypeError: Object(...) is not a function
如何在我的模板中显示返回的可观察对象?我试过像上面那样订阅,我也试过直接在模板中这样做:
this.games = this.afDatabase.list<Game>('/games/', ref => ref.orderByChild(user.uid)).valueChanges();
然后在模板中:
*ngFor="let game of games | async"
导致错误:
Uncaught TypeError: Object(...) is not a function
this.games 是可观察的? gameCol: AngularFirestoreCollection;
games: Observable<Games[]>;
gameArray: Games[];
getAllGames() {
this.gameCol= this.db.collection('games');
return this.gameCol.valueChanges();
}
this.games.getAllGames();
this.games.subscribe(game => {
this.gameArray = game;
});
在HTML
<select class="form-control">
<option [value]="0">Select</option>
<option *ngFor="let game of games">
{{game.something}}
</option>
</select>
我归因于另一个问题的关于我的另一个问题的解决方案解决了这个问题。
需要将 rxjs 从版本 5 更新到版本 6。