Installed Dependencies
"@angular/cli": "1.6.6"
"angularfire2": "5.0.0-rc.6",
"firebase": "4.12.1",
"rxjs": "^5.5.10",
"rxjs-compat": "^6.3.3",
My imports
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database-deprecated';
import { Observable } from 'rxjs/Observable';
import * as firebase from 'firebase/app';
trying to query the FirebaseDatabase with the following method
getMessages(): FirebaseListObservable<ChatMessage[]> {
// Query create list binding
return this.db.list('messages', {
query: { limitToLast: '25' }
});
}
Build returns the following error in the console
error TS2345: Argument of type '{ query: { limitToLast: string; }; }'
is not assignable to parameter of type 'FirebaseListFactoryOpts'.
Types of property 'query' are incompatible.
Type '{ limitToLast: string; }' is not assignable to type 'Query'.
Property 'endAt' is missing in type '{ limitToLast: string; }'.
Issue solved!
Updated angularFire2 to latest
npm install firebase @angular/fire --save
changed the imports (FirebaseListObservable replaced with AngularFireList)
import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
Changed timeSent in the interface model file from "Date = new Date()" to "string"
Removed the square brackets
chatMessages: AngularFireList<ChatMessage>;
getMessages(): AngularFireList<ChatMessage> {
// changed the query since the AngularFireList does it differently.
return this.db.list('messages', ref => ref.orderByKey().limitToLast(25));
}