'{ 查询类型的参数:{ limitTolast: number; orderByKey: bool 值; }; }' 不可分配给类型为“QueryFn”的参数。对象文字只能指定已知属性,并且类型“QueryFn”中不存在“query”。
包.json
"angularfire2": "^5.0.0-rc.3",
"firebase": "^4.5.1",
聊天服务.ts
getMessages(): FirebaseListObservable<ChatMessage[]> {
return this.db.list('messages', {
query: { limitTolast : 25, orderByKey: true}
});
}
最佳答案
它不起作用,因为 AngularFire 需要一个函数作为第二个参数传递。
我认为您的示例是测试版中的正确方法。 (不是 100% 确定)
您已按以下方式使用它:
// make sure to provide a child in the orderByChild call
getMessages(): Observable<ChatMessage[]> {
return this.db.list('/messages', ref => {
return ref.limitTolast(25).orderByKey(true)
});
}
在此处了解有关查询列表的更多信息:https://github.com/angular/angularfire2/blob/master/docs/rtdb/querying-lists.md
关于typescript - “查询”在类型 'QueryFn' 中不存在 | angularfire2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46781760/