diff --git a/src/app/tasks/task/task.component.ts b/src/app/tasks/task/task.component.ts index a207e10..39ecc4e 100644 --- a/src/app/tasks/task/task.component.ts +++ b/src/app/tasks/task/task.component.ts @@ -1,7 +1,8 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, inject, Input, Output} from '@angular/core'; import {Task} from './task.model'; import {CardComponent} from '../../shared/card/card.component'; import {DatePipe} from '@angular/common'; +import {TasksService} from '../tasks.service'; @Component({ selector: 'app-task', @@ -14,9 +15,9 @@ import {DatePipe} from '@angular/common'; }) export class TaskComponent { @Input({ required: true }) task!: Task; - @Output() complete = new EventEmitter(); + tasksService = inject(TasksService); onCompleteTask() { - this.complete.emit(this.task.id); + this.tasksService.removeTask(this.task.id); } } diff --git a/src/app/tasks/tasks.component.html b/src/app/tasks/tasks.component.html index 20e972e..020886b 100644 --- a/src/app/tasks/tasks.component.html +++ b/src/app/tasks/tasks.component.html @@ -17,10 +17,7 @@ diff --git a/src/app/tasks/tasks.component.ts b/src/app/tasks/tasks.component.ts index 4538cbd..d38405a 100644 --- a/src/app/tasks/tasks.component.ts +++ b/src/app/tasks/tasks.component.ts @@ -1,6 +1,5 @@ import {Component, Input} from '@angular/core'; import {type User} from '../user/user.model'; -import {type NewTaskData, type Task} from './task/task.model'; import {TaskComponent} from './task/task.component'; import {NewTaskComponent} from './new-task/new-task.component'; import {TasksService} from './tasks.service'; @@ -21,10 +20,6 @@ export class TasksComponent { return this.tasksService.getUserTasks(this.user.id); } - onCompleteTask(taskId: string) { - this.tasksService.removeTask(taskId); - } - onStartAddTask() { this.isAddingTask = true; }