【发布时间】:2018-06-27 19:02:41
【问题描述】:
我的方法从 Firebase 返回一个 Observable 数组。我决定在客户端而不是服务器中过滤数据。我的问题是,如果属性“attending = true”,我只想获取数据。非常感谢任何帮助或其他方法。非常感谢。
以下方法从firebase实时数据库中获取数据
userEvents: Observable<any[]>;
getUserEvents(uid: string) {
this.userEvents = this.db.list(this.basePatheventsSaved, ref=>
ref.orderByChild('uid').equalTo(uid)).snapshotChanges().map((actions) => {
return actions.map((a) => {
const data = a.payload.val();
const $key = a.payload.key;
return { $key, ...data };
});
});
return this.userEvents;
}
下面的代码用于验证模板中要使用的数据:
userEvents: Observable<any[]>;
constructor(public auth: AuthService, private upSvc: FilesServiceService) {
this.userEvents = this.upSvc.getUserEvents(this.auth.currentUserId);
}
【问题讨论】:
-
呃...
filter运算符不适合您? -
我试过了,但我得到了这个错误“[ts] Property 'attending' does not exist on type 'any[]'.any”
标签: typescript firebase firebase-realtime-database observable angularfire