问题
I am stuck on this error. It seems list method no longer exist in latest version and I am not able to get any clue to fix this error.Also push method does not exist on type AngularFireObject
import { Component } from '@angular/core';
import { AngularFireDatabase, AngularFireObject } 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 {
items: AngularFireObject<any>;
name: any;
msgVal: string = '';
title = 'app';
constructor (public afAuth: AngularFireAuth, public af: AngularFireDatabase) {
this.items = af.database.list('/messages', {
query: {
limitToLast: 5
}
});
this.af.auth.subscribe(auth => {
if(auth) {
this.name = auth;
}
});
}
login() {
this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider());
}
chatSend(theirMessage: string) {
this.items.push({ message: theirMessage, name: this.name.facebook.displayName});
this.msgVal = '';
}
}
Here is the error
回答1:
1) Answer for your first error
You need to use af.list() instead of af.database.list() as it does not exist in recent updates
And according to recent updates you need query the list as shown in the links: LINK1 LINK2 The above links will show you how to declare list and query them.
2) Answer for your second error
There is no such method for push() in the recent update for objects.
Only three methods exists under AngularFireObject: set(value: T), update(value: T) and remove()
For my reference visit this LINK3
来源:https://stackoverflow.com/questions/48171797/property-list-does-not-exist-on-type-database-and-property-push-does-not