import { Component, OnInit } from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; import { NeedListComponent } from '../need-list/need-list.component'; import { HttpClient } from '@angular/common/http'; import { FormsModule } from '@angular/forms'; import { Need, GoalType } from '../../models/Need'; @Component({ selector: 'app-cupboard', standalone: false, templateUrl: './cupboard.component.html', styleUrl: './cupboard.component.css' }) export class CupboardComponent implements OnInit { need: Need = { id: 0, name: '', maxGoal: 0, type: GoalType.MONETARY, filterAttributes: [], current: 0 }; constructor(private cupboardService: CupboardService, private http: HttpClient) { } ngOnInit(): void { console.log('CupboardComponent.ngOnInit'); } submit(form: any) { console.log(form); this.need.name = form.name; this.need.id = form.id; this.need.maxGoal = form.maxGoal; this.need.type = GoalType[form.type as keyof typeof GoalType]; console.log(this.cupboardService.createNeed(this.need)); } }