Skip to content
Permalink
Browse files

fix issues updating the tasks

  • Loading branch information
amejiarosario committed Nov 13, 2019
1 parent d4c5188 commit 0affc599528e8dc5dd18ae5439e7aeb218cb3f84
Showing with 12 additions and 2 deletions.
  1. +1 −1 src/app/todo/todo.component.html
  2. +6 −1 src/app/todo/todo.component.ts
  3. +5 −0 src/app/todo/todo.service.ts
@@ -15,7 +15,7 @@ <h1>Todo</h1>
<ul class="todo-list">
<li *ngFor="let todo of todos" [ngClass]="{completed: todo.isDone, editing: todo.editing}" >
<div class="view">
<input class="toggle" type="checkbox" [checked]="todo.isDone">
<input class="toggle" type="checkbox" [checked]="todo.isDone" (click)="toggleTodo(todo)">
<label (dblclick)="todo.editing = true">{{todo.title}}</label>
<button class="destroy" (click)="destroyTodo(todo)"></button>
</div>
@@ -35,7 +35,7 @@ export class TodoComponent implements OnInit {
getTodos(query = ''){
return this.todoService.get(query).then(todos => {
this.todos = todos;
this.activeTasks = this.todos.filter(todo => todo.isDone).length;
this.activeTasks = this.todos.filter(todo => !todo.isDone).length;
});
}

@@ -59,4 +59,9 @@ export class TodoComponent implements OnInit {
});
}

toggleTodo(todo) {
this.todoService.toggle(todo).then(() => {
return this.getTodos();
});
}
}
@@ -59,4 +59,9 @@ export class TodoService {
});
}

toggle(selected) {
selected.isDone = !selected.isDone;
return Promise.resolve();
}

}

0 comments on commit 0affc59

Please sign in to comment.
You can’t perform that action at this time.