Reputation: 439
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
}
});
}
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.
Upvotes: 1
Views: 630
Reputation: 439
Check your types buddy, you are assigning the query result in different type of firebase datatype this is not going to work debug your code with correct data types and check on Google if there is changes are made to this code due to a version change. Due to consistently changing of versions in Web development technologies this kind of issue is common. Good luck
Upvotes: 0
Reputation: 439
getMessages(): AngularFireList<ChatMessage[]> {
return this.db.list('messages',ref => ref.orderByKey().limitToLast(25));
}
use this instead of that now this will work because FireBaseListObservable is replaced with AngularFirelist.
Upvotes: 1