【问题标题】:Reading data from firebase in ionic 3从 ionic 3 中的 firebase 读取数据
【发布时间】:2018-04-15 12:27:51
【问题描述】:

我想用 ionic 3 从 firebase 数据库中读取数据

我正在使用此代码,但它给了我错误property subscribe does not exist on type AngularFireObject

this.db.object('/incident').subscribe(data => {

this.items = data;

  })

同时,我可以使用以下代码将数据发送到 firebase

sendIncident(){

this.db.list('/incident').push({
    title: this.title.value,
    detail: this.detail.value
})
 }

我会很感激任何关于如何克服这个问题的想法

【问题讨论】:

标签: typescript firebase firebase-realtime-database ionic3 angularfire2


【解决方案1】:

你必须使用这样的东西:

this.subscription = this.db.list('/notes').valueChanges().subscribe(data =>{
 })

【讨论】:

    【解决方案2】:

    我没有使用 ionic 而是 angular 的 angularfire,但这应该适合你

    this.items = this.db.object('/incident').valueChanges();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多