blob: 579565c11077acf7f9faa585310ae65a8c8f8a9b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import { Component } from '@angular/core';
import {Need} from '../../models/Need';
import {CupboardService} from '../../services/cupboard.service';
@Component({
selector: 'app-need-list',
standalone: false,
templateUrl: './need-list.component.html',
styleUrl: './need-list.component.css'
})
export class NeedListComponent {
needs: Need[] = [];
constructor(
private cupboardService: CupboardService
) {}
ngOnInit(): void {
this.cupboardService.getNeeds().subscribe(n => this.needs = n)
}
delete(id : number) {
this.cupboardService.deleteNeed(id).subscribe(() => {
this.needs = this.needs.filter(n => n.id !== id)
})
}
}
|