类型'{} []'不能分配给'AngularFireList <any []>'

时间:2018-01-04 22:47:19

标签: angular firebase angularfire5

我是Angular和Firebase的新手,我正在尝试将节点的所有项目都添加到AgularFireList中,但是我收到了这个错误:

类型'{} []'不能分配给'AngularFireList'类型。   “{} []'类型中缺少属性”查询“。

我的代码是:

my_notes: AngularFireList<any[]>;

constructor(public afDB: AngularFireDatabase) {
    this.getNotes()
      .subscribe(
        notas => {
          this.my_notes = notas;
        }
      );
  }

  getNotes(){
    return this.afDB.list('/notas').valueChanges();
  }

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

试试这个:

constructor(public afDB: AngularFireDatabase) {
this.getNotes()
  .subscribe(
    (notas: AngularFireList<any[]>) => {
      this.my_notes = notas;
    }
  );
}

如果问题仍然存在,请尝试添加以下代码:

getNotes(){
    return <Observable<AngularFireList<any[]>>>this.afDB.list('/notas').valueChanges();
  }
相关问题