Runtime Error this.object.remove is not a function

余生长醉 提交于 2019-12-08 05:23:31

Issue is your this.employees is not a reference to the real-time database after calling valueChanges() but is an Observable of the list data. Have a separate variable pointing to the reference. If you want the key, use snapShotChanges()

empRef:any;//the reference

constructor(
    public navCtrl   : NavController,
    public navParams : NavParams,
    public empDb     : AngularFireDatabase
  )
  {
    this.empRef = this.empDb.list('/emloyeesionic');
    this.employees = this.empRef.snapshotChanges();
  }

In deleteEmployee function, use the reference to delete the item from the list.

deleteEmployee(key: string)
  {
    this.empRef.remove(key);
  }

In your HTML, you will get actual value in employee.payload.val() and key in employee.payload.key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!