Permalink
Browse files

Clearing out completed tasks

  • Loading branch information...
amejiarosario committed Oct 19, 2016
1 parent fd0a228 commit 333c0127f1fcc7949e0b0138933dc6aaf7044fe3
Showing with 14 additions and 1 deletion.
  1. +1 −1 src/app/todo/todo.component.html
  2. +6 −0 src/app/todo/todo.component.ts
  3. +7 −0 src/app/todo/todo.service.ts
@@ -51,6 +51,6 @@ <h1>Todo</h1>
</li>
</ul>
<!-- Hidden if no completed items are left ↓ -->
<button class="clear-completed">Clear completed</button>
<button class="clear-completed" (click)="clearCompleted()">Clear completed</button>
</footer>
</section>
@@ -52,4 +52,10 @@ export class TodoComponent implements OnInit {
return this.getTodos();
});
}
clearCompleted() {
this.todoService.deleteCompleted().then(() => {
return this.getTodos();
});
}
}
@@ -49,4 +49,11 @@ export class TodoService {
resolve(true);
});
}
deleteCompleted() {
return new Promise(resolve => {
todos = todos.filter(todo => !todo.isDone);
resolve(todos);
});
}
}

1 comment on commit 333c012

@Sillyon

This comment has been minimized.

Show comment
Hide comment
@Sillyon

Sillyon Sep 7, 2017

it says:

Failed to compile.
../Todos/src/app/todo/todo.service.ts (55,7): Cannot assign to 'todos' because it is a constant or a read-only property.

Sillyon commented on 333c012 Sep 7, 2017

it says:

Failed to compile.
../Todos/src/app/todo/todo.service.ts (55,7): Cannot assign to 'todos' because it is a constant or a read-only property.

Please sign in to comment.