From fd41663f868c433cd109e4e39829af71a15435f0 Mon Sep 17 00:00:00 2001 From: Toast Date: Wed, 5 Feb 2025 01:51:15 +0100 Subject: [PATCH] Components/create-edit-modal: move FormGroup init to separate function --- .../create-edit-modal/create-edit-modal.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/create-modal/create-edit-modal/create-edit-modal.component.ts b/src/components/create-modal/create-edit-modal/create-edit-modal.component.ts index ca412ee..faffd99 100644 --- a/src/components/create-modal/create-edit-modal/create-edit-modal.component.ts +++ b/src/components/create-modal/create-edit-modal/create-edit-modal.component.ts @@ -4,6 +4,7 @@ import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/ import {ShowsApiService} from '../../../services/shows/shows-api.service'; import {ShowsApiCreation} from '../../../interfaces/shows-api-creation'; import {ToastService} from '../../../services/toast/toast.service'; +import {Show} from '../../../interfaces/show'; @Component({ selector: 'app-create-edit-modal', @@ -17,12 +18,16 @@ export class CreateEditModalComponent { private activeModal = inject(NgbActiveModal) private showsService = inject(ShowsApiService) private toastService = inject(ToastService) - protected newShowForm: FormGroup + protected newShowForm: FormGroup = new FormGroup({}) protected editMode: boolean = false protected show?: Show constructor() { + this.initForm() + } + + private initForm() { this.newShowForm = new FormGroup({ title: new FormControl(this.show?.title, Validators.required), date: new FormControl(this.show?.date, Validators.required),