AngularFIRE Property 'subscribe' does not exist on type 'AngularFireList<{}>'

后端 未结 5 1703
名媛妹妹
名媛妹妹 2021-02-06 03:18

I\'m following this tutorial about how to connect angular with firebase database. But in minute 17:30 I\'m getting this error:

Property \'subscribe\' does not ex

5条回答
  •  半阙折子戏
    2021-02-06 03:50

    Try the next:

    export class AppComponent {
      countries: any[];
    
      constructor(db: AngularFireDatabase )
      {
          this.countries = db.list('/Country/countries').valuesChanges();
      }
    }
    

    And if you have a model then:

    export class AppComponent {
      countries: Country[];
    
      constructor(db: AngularFireDatabase )
      {
         this.countries = db.list('/Country/countries').valueChanges();
      }
    }
    

提交回复
热议问题