อ่านข้อมูลจาก firebase ใน ionic 3

ฉันต้องการอ่านข้อมูลจากฐานข้อมูล firebase ด้วย ionic 3

ฉันใช้รหัสนี้แต่มันทำให้ฉันมีข้อผิดพลาด 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
})
 }

ฉันจะขอบคุณความคิดใด ๆ เกี่ยวกับวิธีการเอาชนะสิ่งนี้




คำตอบ (2)


ฉันไม่ได้ใช้ไอออนิก แต่เป็นเชิงมุมกับแองกูลาร์ไฟร์ แต่สิ่งนี้น่าจะเหมาะกับคุณ

this.items = this.db.object('/incident').valueChanges();
person Hareesh    schedule 02.11.2017

คุณต้องใช้สิ่งนี้:

this.subscription = this.db.list('/notes').valueChanges().subscribe(data =>{
 })
person Kachailo Dmytro    schedule 05.12.2017