diff --git a/src/app/todo/todo.component.html b/src/app/todo/todo.component.html index 89d5cfc..8e7029c 100644 --- a/src/app/todo/todo.component.html +++ b/src/app/todo/todo.component.html @@ -38,13 +38,13 @@

Todo

diff --git a/src/app/todo/todo.component.ts b/src/app/todo/todo.component.ts index 4848dfe..60db372 100644 --- a/src/app/todo/todo.component.ts +++ b/src/app/todo/todo.component.ts @@ -1,4 +1,6 @@ import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + import { TodoService } from './todo.service'; @Component({ @@ -11,8 +13,16 @@ export class TodoComponent implements OnInit { private todos; private activeTasks; private newTodo; + private path; + + constructor(private todoService: TodoService, private route: ActivatedRoute) { } - constructor(private todoService: TodoService) { } + ngOnInit() { + this.route.params.subscribe(params => { + this.path = params['status']; + this.getTodos(); + }); + } addTodo(){ this.todoService.add({ title: this.newTodo, isDone: false }).then(() => { @@ -37,10 +47,6 @@ export class TodoComponent implements OnInit { }); } - ngOnInit() { - this.getTodos(); - } - destroyTodo(todo) { this.todoService.delete(todo).then(() => { return this.getTodos();