Reputation: 489
I am creating an AngularFire app, and this is the code in my app.component.ts:
import { Component } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable } from
'angularfire2/database';
import { AngularFireAuth } from 'angularfire2/auth';
import { Observable } from 'rxjs/Observable';
import * as firebase from 'firebase/app';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
user: Observable<firebase.User>;
items: FirebaseListObservable<any[]>;
msgVal: string = '';
constructor(public afAuth: AngularFireAuth, public af: AngularFireDatabase) {
this.items = af.list('/messages', {
query: {
//I am using a limitToLast: 50 here, but isn't working.
}
});
this.user = this.afAuth.authState;
}
}
The problem is that it isn't compiling, and my text editor (vs code) is returning the following errors:
when I hover over query: {
: [ts]
Argument of type '{ query: { limitToLast: number; }; }' is not assignable to parameter of type 'QueryFn'. Object literal may only specify known properties, and 'query' does not exist in type 'QueryFn'.
I can't seem to be able to find the problem, why is this happening?
Upvotes: 0
Views: 2210
Reputation: 10860
I guess you are using the last angularfire2 and firebase version, as I had the same exception. They changed several things with the latest update. Here a link to angularfire2 latest docs.
In your case you can fix it like this:
constructor(public afAuth: AngularFireAuth, public af: AngularFireDatabase) {
this.items = af.list('/messages', ref => ref.orderByKey(true).limitToLast(50));
});
this.user = this.afAuth.authState;
}
Upvotes: 2