我坚持这个错误。似乎list方法在最新版本中不再存在,我无法得到任何线索来修复此错误。而且类型AngularFireObject上也不存在push方法
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 = '';
}
}