Add task delete + form for add and update
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user