Created
April 18, 2024 14:40
-
-
Save zzpzaf/d4d6ed7bf11663c6a92b6095a685f1e0 to your computer and use it in GitHub Desktop.
dynamicform1_RequestDataComponent_c11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; | |
import { ItemsFormFieldsService } from '../items-form-fields.service'; | |
import { Subscription } from 'rxjs'; | |
@Component({ | |
selector: 'app-request-data', | |
templateUrl: './request-data.component.html', | |
styleUrls: ['./request-data.component.scss'] | |
}) | |
export class RequestDataComponent { | |
fornCardTitle: string = 'My Demo Form'; | |
demoFormGroup!: FormGroup; | |
input1Label: string = 'Item Id'; | |
input1Placeholder: string = 'Input Id here'; | |
input1ControlNane: string = 'itemId'; | |
constructor( | |
private formBuilder: FormBuilder, | |
private itemFormFieldsService: ItemsFormFieldsService | |
) { } | |
ngOnInit(): void { | |
// this.updateCategories(); | |
this.initializeForm(); | |
this.demoFormGroup.valueChanges.subscribe(val => { | |
const id = this.demoFormGroup.get(this.input1ControlNane)?.value; | |
if (id == undefined || id == null || id == '' || id <= 0) return; | |
this.itemFormFieldsService.setItemId(id!); | |
}); | |
} | |
initializeForm(): void { | |
const fbGroup = this.formBuilder.group({}); | |
fbGroup.addControl(this.input1ControlNane, new FormControl("")); | |
this.demoFormGroup = fbGroup; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment