Bonjour,

Je reçois ce message d'erreur alors que mon boutton update Task fonctionnais très bien, et la il m'indique ceci à présent, et TasksComponent est bien la dans mon code ci dessous.

Pouvez vous m'aider ?

ERROR in src/app/components/tasks/tasks.component.html:28:22 - error TS2339: Property 'updateTask' does not exist on type 'TasksComponent'.

28 <button (click)="updateTask()" class="btn btn-warning btn-block">
~~~~~~~~~~~~

src/app/components/tasks/tasks.component.ts:7:16
7 templateUrl: './tasks.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component TasksComponent.

fichier : tasks.component.html

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
<button (click)="updateTask()" class="btn btn-warning btn-block">
        <i class="fa fa-refresh"></i> update Task
    </button>
 
    <button (click)="persistTask()" class="btn btn-success btn-block">
            <i class="fa fa-send"></i> New Task
    </button>

fichier : tasks.component.ts

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import{ TaskService } from './../../services/task.service';
import { Component, OnInit } from '@angular/core';
import { Task } from 'src/app/models/task';
 
@Component({
  selector: 'app-tasks',
  templateUrl: './tasks.component.html',
  styleUrls: ['./tasks.component.css']
})
export class TasksComponent implements OnInit {
 
  editForm = false;
 
  myTask: Task = {
    label: '',
    completed: false
  } 
  tasks: Task[] = [];
 
  constructor(private taskService: TaskService) { }
 
  ngOnInit() {
    this.getTasks();
  }
 
  getTasks() {
    this.taskService.findAll()
      .subscribe(tasks => this.tasks = tasks)
  } 
 
  deleteTask(id){
    this.taskService.delete(id)
        .subscribe(() => {
          this.tasks = this.tasks.filter(task => task.id != id)
        })
  } 
 
  persistTask() {
    this.taskService.persist(this.myTask)
    .subscribe((task) => { 
    this.tasks = [task, ...this.tasks];
    this.restTask();
    })
  } 
 
  restTask() {
    this.myTask = {
      label: '',
      completed: false
    } 
  } 
 
  toggleCompleted(task) {
    this.taskService.completed(task.id, task.completed)
    .subscribe(() => {
      task.completed = !task.completed
    })
  } 
 
  editTask(task) {
    this.myTask = task
    this.editForm = true;
  } 
 
}