Created
March 2, 2017 14:30
-
-
Save brunokrebs/a59c0451b32c0742cf3c76c57f131f8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { TaskListService } from './task-list.service'; | |
@Component({ | |
selector: 'app-task-list', | |
templateUrl: './task-list.component.html', | |
styleUrls: [ './task-list.component.css' ] | |
}) | |
export class TaskListComponent implements OnInit { | |
private tasks: String[]; | |
constructor(private taskListService: TaskListService) { } | |
ngOnInit() { this.loadTasks(); } | |
private loadTasks() { | |
this.taskListService.loadTasks$().subscribe( | |
response => this.tasks = response.json(), | |
error => console.log(error) | |
); | |
} | |
taskAddedHandler(task) { | |
this.taskListService.addTask$(task).subscribe( | |
response => this.loadTasks(), | |
error => console.log() | |
); | |
} | |
deleteTask(task) { | |
this.taskListService.deleteTask$(task).subscribe( | |
response => this.loadTasks(), | |
error => console.log() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment