Add delete button in the TaskListComponent
- ✔️Trigger task deletionAdd a delete button in the TaskListComponent class to remove a task from the list.
The delete button
Let’s update the TaskListComponent class to add a delete button next to each task in the list. When the user clicks the delete button, the task will be removed from the list.
🎓 Instructions
-
Update the
src/app/task-list/task-list.component.html
file.
The deleteTask function
Let’s create the deleteTask function in the TaskListComponent class to remove a task from the list. It’ll call the deleteTask function from the TaskService class to remove the task from the list.
🎓 Instructions
-
Update the
src/app/task-list/task-list.component.ts
file.
Let’s test it out
- Click on the ‘Delete’ button next to a task in the list.
- The task should be removed from the list.
✔️ What you learned
You are now able to delete a task from the list from the TaskListComponent Component.