从Ionic 4的Firebase列表中删除项目

时间:2018-10-30 04:43:47

标签: angular firebase ionic-framework ionic4

home.ts 通过按键从ionic4中删除Firebase列表中的项目

export class HomePage {
shop : AngularFireList<any>;
shopadd : Observable<any[]>;
constructor(
public navCtrl: NavController,
public db: AngularFireDatabase, 
public navParams: NavParams,
public auth: AngularFireAuth
){
this.shopadd = this.db.list('/market').valueChanges(); 
this.shopadd = this.db.list('/market').snapshotChanges().map(changes => {
  return changes.map(c => ({ key: c.payload.key, ...c.payload.val()
})); 
}); 
  }

这不起作用

  delete(key){this.shop.remove(key);}}

home.html中的此按钮

<button ion-button clear item-end (click)="delete(shopadd.key)"> delete </button>

0 个答案:

没有答案