您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

49 行
1.4 KiB

  1. import {Component} from '@angular/core';
  2. import {FormGroup} from "@angular/forms";
  3. import {contactForm} from "@app/_forms/apiForms";
  4. import {ContactJsonld, ContactService} from "@app/core/api/v1";
  5. import {Subscription} from "rxjs";
  6. @Component({
  7. selector: 'app-new-contact',
  8. templateUrl: './new-contact.component.html',
  9. styleUrl: './new-contact.component.scss'
  10. })
  11. export class NewContactComponent {
  12. protected contactForm: FormGroup;
  13. protected selectedImage: File | null;
  14. protected contactSub: Subscription;
  15. constructor(
  16. private contactService: ContactService
  17. ) {
  18. this.contactForm = contactForm;
  19. this.selectedImage = null;
  20. this.contactSub = new Subscription();
  21. }
  22. onSubmit() {
  23. if (this.contactForm.valid) {
  24. // Hier können Sie die Daten senden oder weitere Aktionen durchführen
  25. console.log(this.selectedImage);
  26. console.log('Formular wurde gesendet:', this.contactForm.value);
  27. this.contactSub = this.contactService.contactsPost(
  28. this.contactForm.value as ContactJsonld
  29. ).subscribe(
  30. data => {
  31. console.log(data);
  32. }
  33. );
  34. }
  35. }
  36. onFileSelected(event: any) {
  37. const file: File = event.target.files[0];
  38. if (file) {
  39. this.selectedImage = file;
  40. }
  41. }
  42. }