Search code examples
angularfirebaseangularfire5

Type '{}[]' is not assignable to type 'AngularFireList<any[]>'


I'm new with Angular and Firebase, I'm trying to get all of my items of a node to an AgularFireList, but I get this error:

Type '{}[]' is not assignable to type 'AngularFireList'. Property 'query' is missing in type '{}[]'.

My code is:

my_notes: AngularFireList<any[]>;

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

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

Thanks for the help.


Solution

  • Try this:

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

    If the issue still persists, try also adding this bit of code:

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