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) }) } }