Add task delete + form for add and update

This commit is contained in:
jfhr
2020-06-03 16:21:47 +02:00
parent f52485761e
commit 0bd4205d02
8 changed files with 126 additions and 25 deletions

View File

@@ -11,10 +11,29 @@ export class TaskListComponent implements OnInit {
public tasks: Task[] = [];
constructor(private backendService: BackendService) {
backendService.getTasks().subscribe(t => this.tasks.push(...t));
backendService.getTasks().subscribe(response => {
if (response.status > 399) {
alert('Fehler');
}
else {
this.tasks.push(...response.body);
}
});
}
ngOnInit(): void {
}
public deleteTask(task: Task) {
this.backendService.deleteTask(task).subscribe(response => {
if (response.status > 399) {
alert('Fehler');
}
});
const index = this.tasks.indexOf(task);
if (index !== -1) {
this.tasks.splice(index, 1);
}
}
}