I hope you can help me, I've been looking for a long time and I have not achieved anything. The Fields of "x" Document I add it in a table in HTML, and I have added two buttons, to edit and to eliminate, what I want is to obtain the Document from where the Field of the row of the button comes, finally to be able to eliminate it. It's like making a get of the Field's index. I'm using Angular and AngularFire2
Provider
private sprintCollection: AngularFirestoreCollection<Sprint>;
private itemDoc: AngularFirestoreDocument<any>;
sprints: Sprint[] = [];
item:any[]=[];
constructor( private afs: AngularFirestore ) {
this.sprintCollection = this.afs.collection<Sprint>('Sprints');
}
getSprint(value:string){
this.sprintCollection = this.afs.collection('Sprints', ref => ref.where('Application', '==', value) )
return this.sprintCollection.valueChanges();
}
getSprints(){
return this.sprintCollection.valueChanges();
}
addSprint( sprint:Sprint){
return this.sprintCollection.add(sprint);
}
Component
this._sp.getSprints().subscribe(data=>{
for(let key$ in data){
let h =data[key$]
h.key$ = key$
this.sprintGrid.push(data[key$]);
}
});
HTML
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">Sprint</th>
<th scope="col">Aplication</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let sprint of sprintGrid; let i = index">
<td>{{ sprintGrid[i].Sprint }}</td>
<td>{{ sprintGrid[i].Application }}</td>
<td>
<button kendoButton style="background-color: #ffc107; color:white" class="col-lg-4" [icon]="'edit'" ></button>
<button kendoButton style="background-color: #dc3545; color:white" (click)="delete(sprintGrid[i].key$)" class="col-lg-4" [icon]="'delete'" ></button>
</td>
</tr>
</tbody>
</table>