Inject Service in form component
- βοΈUse TaskService to create a taskUse TaskService from TaskFormComponent to creat a new task
Inject the TaskService in the TaskFormComponent
π Instructions
-
Update the
src/app/task-form.component.ts
file.
The TaskFormComponent class is now using the TaskService to add a new task to the list.
Letβs test it out
- Go back to your browser
- Click on the
Add a new task
link - Enter a title and a description in the form
- Click on the
Create task
button - Click on the
List of tasks
link
You should see the new task in the list.
βοΈ What you learned
You learned how to use the TaskService once gain, this time to trigger the addTask function to add a new task to the task list.