属性"list"在类型"database"上不存在,并且属性"push"在类型"AngularFireObject< any>"上不存在. [英] Property 'list' does not exist on type 'database' and, Property 'push' does not exist on type 'AngularFireObject<any>

查看:134
本文介绍了属性"list"在类型"database"上不存在,并且属性"push"在类型"AngularFireObject< any>"上不存在.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被卡在这个错误上.似乎列表方法在最新版本中不再存在,我无法获得任何纠正此错误的线索.在AngularFireObject类型上也不存在push方法

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 = '';
}
  }

这是错误

推荐答案

1)回答您的第一个错误

1) Answer for your first error

您需要使用af.list()而不是af.database.list(),因为它在最近的更新中不存在

You need to use af.list() instead of af.database.list() as it does not exist in recent updates

根据最新更新,您需要查询列表,如链接所示: LINK1 LINK2 上面的链接将向您展示如何声明列表和查询它们.

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)回答第二个错误

在最近的对象更新中,没有用于push()的方法.

There is no such method for push() in the recent update for objects.

AngularFireObject下仅存在三种方法:set(value:T),update(value:T)和remove()

Only three methods exists under AngularFireObject: set(value: T), update(value: T) and remove()

供我参考,请访问 LINK3

这篇关于属性"list"在类型"database"上不存在,并且属性"push"在类型"AngularFireObject&lt; any&gt;"上不存在.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆