From 5b2f25b6bd1ef11cf2f4d35926c19ae40c14a05d Mon Sep 17 00:00:00 2001 From: ExostFlash Date: Wed, 26 Nov 2025 16:12:59 +0100 Subject: [PATCH] modif task service --- src/app/service/task.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/service/task.service.ts b/src/app/service/task.service.ts index 9dd166e..65ea1c9 100644 --- a/src/app/service/task.service.ts +++ b/src/app/service/task.service.ts @@ -2,6 +2,11 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, of } from 'rxjs'; import { delay } from 'rxjs/operators'; +export interface TaskItem { + id: number; + title: string; +} + @Injectable({ providedIn: 'root' }) @@ -17,11 +22,11 @@ export class TaskService { return of(this.tasks).pipe(delay(1000)); } - private tasksSubject = new BehaviorSubject(this.tasks); + private tasksSubject = new BehaviorSubject(this.tasks); tasks$ = this.tasksSubject.asObservable(); addTask(title: string) { - const newTask = { id: this.nextId++, title: title.trim() }; + const newTask: TaskItem = { id: this.nextId++, title: title.trim() }; this.tasks.push(newTask); this.tasksSubject.next([...this.tasks]); }