1 import {Component, Input, OnChanges, SimpleChanges} from "@angular/core";
2 import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
3 import {FormGroup} from "@angular/forms";
6 selector: 'dropdown-form-control',
7 templateUrl: './dropdown.formControl.component.html',
8 styleUrls : ['./dropdown.formControl.component.scss']
10 export class DropdownFormControlComponent implements OnChanges{
11 @Input() data: DropdownFormControl = null;
12 @Input() form: FormGroup = null;
14 ngOnChanges(changes: SimpleChanges): void {
15 if (changes["data"] !== undefined && changes["data"].currentValue !== changes["data"].previousValue && changes["data"].firstChange) {
17 this.data.onInit(this.data, this.form);
21 if (changes["data"] !== undefined) {
22 this.form.controls[this.data.controlName].valueChanges.subscribe((value)=>{
23 this.data.onChange(value, this.form);