import {Component} from '@angular/core'; import {FormGroup} from "@angular/forms"; import {contactForm} from "@app/_forms/apiForms"; import {ContactJsonld, ContactService} from "@app/core/api/v1"; import {Subscription} from "rxjs"; @Component({ selector: 'app-new-contact', templateUrl: './new-contact.component.html', styleUrl: './new-contact.component.scss' }) export class NewContactComponent { protected contactForm: FormGroup; protected selectedImage: File | null; protected contactSub: Subscription; constructor( private contactService: ContactService ) { this.contactForm = contactForm; this.selectedImage = null; this.contactSub = new Subscription(); } onSubmit() { if (this.contactForm.valid) { // Hier können Sie die Daten senden oder weitere Aktionen durchführen console.log(this.selectedImage); console.log('Formular wurde gesendet:', this.contactForm.value); this.contactSub = this.contactService.contactsPost( this.contactForm.value as ContactJsonld ).subscribe( data => { console.log(data); } ); } } onFileSelected(event: any) { const file: File = event.target.files[0]; if (file) { this.selectedImage = file; } } }