类型'{的参数:查询:{limitToLast:数字; orderByKey:布尔值; }; }"不可分配给"FirebaseListFactoryOpts"类型的参数 [英] Argument of type '{ query: { limitToLast: number; orderByKey: boolean; }; }' is not assignable to parameter of type 'FirebaseListFactoryOpts'
本文介绍了类型'{的参数:查询:{limitToLast:数字; orderByKey:布尔值; }; }"不可分配给"FirebaseListFactoryOpts"类型的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
user: any;
chatMessages: FirebaseListObservable<ChatMessage[]>;
chatMessage: ChatMessage;
userName: Observable<string>;
constructor(
public db: AngularFireDatabase,
public afAuth: AngularFireAuth,
) {
this.afAuth.authState.subscribe(auth => {
if (auth !== undefined && auth !== null){
this.user = auth;
}
});
}
sendMessage(msg: string){
const timestamp = this.getTimeStamp();
const email = this.user.email;
this.chatMessages = this.getMessages();
this.chatMessages.push({
message: msg,
timeSent: timestamp,
userName: this.userName,
email: email});
}
getMessages(): FirebaseListObservable<ChatMessage[]>{
return this.db.list('/messages', {
query: {
limitToLast: 25,
orderByKey: true
}
});
}
我正在使用angular和firebase制作一个网络聊天应用程序,然后出现此错误,即查询不是FireBaseListFactoryOpts的兼容类型. 如果有人可以,请提供帮助.
i was making a web chat app using angular and firebase then i got this error that query is not a compatible type of FireBaseListFactoryOpts. please help if anyone can.
推荐答案
getMessages(): AngularFireList<ChatMessage[]> {
return this.db.list('messages',ref => ref.orderByKey().limitToLast(25));
}
使用它代替现在使用,因为FireBaseListObservable被AngularFirelist取代了.
use this instead of that now this will work because FireBaseListObservable is replaced with AngularFirelist.
这篇关于类型'{的参数:查询:{limitToLast:数字; orderByKey:布尔值; }; }"不可分配给"FirebaseListFactoryOpts"类型的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文