Delete

Service

deleteStudent(id: string): Promise<void> {
  const studentDoc = doc(this.firestore, 'students', id);
  return deleteDoc(studentDoc);
}

Component

onDelete(id: string) {
  this.studentService.deleteStudent(id).then(() => {
    console.log('Deleted student with ID: ' + id);
  });
}

Template

<button (click)="onDelete(item.id)" type="button" class="btn btn-danger">
  Delete
</button>
Was this page helpful?