<h1>My Exciting To Do List</h1>
<input #newTask>
<button (click)="addTask(newTask.value)">Add Task</button>
<ul>
<li *ngFor="let task of tasks">{{task.name}}</li>
</ul>
export class MyToDoAppComponent implements OnInit {
title = 'awesome-todo-app';
tasks:any;
constructor(private taskService:TaskService) {}
ngOnInit() {
this.taskService.getTasks()
.subscribe(response => {
this.tasks = response;
console.log(this.tasks)
})
}
addTask(name: string){
this.tasks.push({
taskId: 1,
name, completed: false
});
console.log(this.tasks)
}
This is the progress I've made so far and any assistance would be greatly appreciated :)
I've searched extensively on various platforms for a solution, but unfortunately haven't found one that works.