Components/create-edit-modal: move FormGroup init to separate function
This commit is contained in:
parent
be31699167
commit
fd41663f86
1 changed files with 6 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/
|
||||||
import {ShowsApiService} from '../../../services/shows/shows-api.service';
|
import {ShowsApiService} from '../../../services/shows/shows-api.service';
|
||||||
import {ShowsApiCreation} from '../../../interfaces/shows-api-creation';
|
import {ShowsApiCreation} from '../../../interfaces/shows-api-creation';
|
||||||
import {ToastService} from '../../../services/toast/toast.service';
|
import {ToastService} from '../../../services/toast/toast.service';
|
||||||
|
import {Show} from '../../../interfaces/show';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-create-edit-modal',
|
selector: 'app-create-edit-modal',
|
||||||
|
|
@ -17,12 +18,16 @@ export class CreateEditModalComponent {
|
||||||
private activeModal = inject(NgbActiveModal)
|
private activeModal = inject(NgbActiveModal)
|
||||||
private showsService = inject(ShowsApiService)
|
private showsService = inject(ShowsApiService)
|
||||||
private toastService = inject(ToastService)
|
private toastService = inject(ToastService)
|
||||||
protected newShowForm: FormGroup
|
protected newShowForm: FormGroup = new FormGroup({})
|
||||||
|
|
||||||
protected editMode: boolean = false
|
protected editMode: boolean = false
|
||||||
protected show?: Show
|
protected show?: Show
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
this.initForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
private initForm() {
|
||||||
this.newShowForm = new FormGroup({
|
this.newShowForm = new FormGroup({
|
||||||
title: new FormControl(this.show?.title, Validators.required),
|
title: new FormControl(this.show?.title, Validators.required),
|
||||||
date: new FormControl(this.show?.date, Validators.required),
|
date: new FormControl(this.show?.date, Validators.required),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue