I have firebase (realtime database) simple structure like this:
Listing all items in view:
<ion-list>
<ion-item *ngFor="let item of arrData; let i = index" (click)="delete(item)">
{{i+1}}. {{item.name}}<small> - {{item.address}}</small>
</ion-item>
</ion-list>
In controller the database is defined, because showing and adding data is working:
arrData = []
constructor(public navCtrl: NavController, private fdb: AngularFireDatabase) {
this.fdb.list("/schools/").valueChanges().subscribe(data =>{
this.arrData = data;
console.log(this.arrData);
})
btnAddClicked(){
this.fdb.list("/schools/").push({name:this.schoolName, address:this.schoolAddress});
}
I want to delete item when it is selected (clicked). From documentation I understand that it is possible to use .remove(), just need path to item. But for that I need to get that auto-generated key. How to get that? Or is there another way to remove selected item?