import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from '@angular/core'; import { FormGroup, FormArray } from '@angular/forms'; import { DynamicFieldDependency } from '../../../models/data-managemnt-plans/DynamicFieldDependency'; @Component({ selector: 'app-dynamic-fields-project', templateUrl: 'dynamic-fields-project.component.html', styleUrls: ['./dynamic-fields-project.component.scss'], encapsulation: ViewEncapsulation.None }) export class DynamicFieldsProjectComponent implements OnInit { @Input() formGroup: FormGroup; ngOnInit(): void { } findDependencies(id: number) { const formGroupDependencies: Array = new Array(); const dynamicFieldDependency: DynamicFieldDependency[] = (this.formGroup.get('dynamicFields')).at(id).get('dependencies').value; if (dynamicFieldDependency.length > 0) { dynamicFieldDependency.forEach(item => { const length = (this.formGroup.get('dynamicFields')).length; for (let i = 0; i < length; i++) { const formGroup = (this.formGroup.get('dynamicFields')).at(i); if (formGroup.get('id').value === item.id) { formGroupDependencies.push(formGroup); } } }); } return formGroupDependencies; } }