坚持按值/子键删除父按键

时间:2017-11-27 11:20:00

标签: javascript firebase firebase-realtime-database ionic2 angularfire

我想通过value / childkey删除父按键:

export class FaqsPage {
  qS: Observable<any[]>;
  ques = '';
  ans = '';

constructor(private db: AngularFireDatabase) {}
ionViewDidLoad() { this.qS = this.db.list('table/faq').valueChanges(); }

removeItem(id){this.db.list('table/faq').remove(id);}

removeItem()删除整个所有按键。难怪因为我无法获得父密钥

//faq.html
<ion-list>
    <ion-item-sliding *ngFor="let el of qS | async">
      <ion-item>
        <b>{{ el.Q }}</b><br>{{ el.A }}
      </ion-item>
      <ion-item-options side="right">
        <button ion-button color="red" icon-only (click)="removeItem(el.key)"><ion-icon name="trash"></ion-icon></button>
      </ion-item-options>
    </ion-item-sliding>
  </ion-list>

el.key 因为 valueChanges()而无法获得密钥(例如 Kzwv8d_i-0QZuf2NT8Z ) strong>我不知道如何在当前迭代中

enter image description here

0 个答案:

没有答案