Typescript 如何在ionic 3 real time Firebase中从数据列表中删除特定数据
我可以上传和获取数据,但我想使用按钮从数据列表中删除数据。 下面是我的代码Typescript 如何在ionic 3 real time Firebase中从数据列表中删除特定数据,typescript,firebase,ionic-framework,firebase-realtime-database,ionic3,Typescript,Firebase,Ionic Framework,Firebase Realtime Database,Ionic3,我可以上传和获取数据,但我想使用按钮从数据列表中删除数据。 下面是我的代码 ionViewDidLoad() { console.log('ionViewDidLoad PagesAllpatientsPage'); this.ph.getPatientProfile(this.id).once('value', snapshot => { this.patientsList = []; console.log('sjiy') snaps
ionViewDidLoad() {
console.log('ionViewDidLoad PagesAllpatientsPage');
this.ph.getPatientProfile(this.id).once('value', snapshot => {
this.patientsList = [];
console.log('sjiy')
snapshot.forEach(snap => {
this.patientsList.push({
id: snap.key,
name: snap.val().name,
age: snap.val().age,
gender: snap.val().gender,
phonenumber: snap.val().phonenumber,
});
console.log(this.patientsList)
return false
});
});
}
deletePatient(id:any,) {
firebase.database().ref(`userProfile/${this.user.uid}/PatientInfo/${id}`).remove(id)
}
我只想通过点击按钮从patientInfo中删除一个数据,请同时提供
删除记录
我知道有点晚了,但它可能会帮助有需要的人
/* this will help you get the ref of unique id of the current data */
uid = **apH....q1e2** in this case
let ref = this.afDatabase.database.ref('userProfile/' + uid + 'PatientInfo');
/* now to remove patient info */
ref.remove().then(data => {
console.log('Data removed successfully.');
})
我知道有点晚了,但它可能会帮助有需要的人
/* this will help you get the ref of unique id of the current data */
uid = **apH....q1e2** in this case
let ref = this.afDatabase.database.ref('userProfile/' + uid + 'PatientInfo');
/* now to remove patient info */
ref.remove().then(data => {
console.log('Data removed successfully.');
})