This is my html code which is basically a form.
<form [formGroup]="calculatedForm" fxLayout="column" fxLayoutGap="15px" fxLayoutAlign="start space-betwen">
<label for="category">CATEGORY</label>
<app-toggle-button-group
[items]="categories"
[selectedItem]="getselectedCategory()"
(valueChange)="updateCategory($event)"
[disableButtons]="calculatedForm.value.system">
</app-toggle-button-group>
<label for="input_interval">INTERVAL</label>
<app-toggle-button-group
[items]="inputIntervals"
[selectedItem]="getselectedInterval()"
(valueChange)="updateInterval($event)"
[disableButtons]="calculatedForm.value.system">
</app-toggle-button-group>
<label for="aggregation">AGGREGATION</label>
<app-toggle-button-group
[items]="aggregations"
[selectedItem]="getselectedAggregation()"
(valueChange)="updateAggregation($event)"
[disableButtons]="calculatedForm.value.system">
</app-toggle-button-group>
<app-kpi-unit
[selectedUnitID]="selectedUnitId()"
(changedUnitID)= "selectUnit($event)"
[disableSelect]="calculatedForm.value.system">
</app-kpi-unit>
</form>
this is my form property in controller
calculatedForm = this.formBuilder.group({
id: new FormControl(''),
identifier: new FormControl(''),
category: new FormControl('', [Validators.required]),
aggregation: new FormControl(null, [Validators.required]),
input_interval: new FormControl('', [Validators.required]),
operator: new FormControl('', [Validators.required]),
unit_id: new FormControl(null),
org_unit: new FormControl('', [Validators.required]),
system: new FormControl(false),
deleted: new FormControl(false),
assignedKpiId: new FormControl(null)
});
As you can see in html code I am using a method from event emitted by components to update my form controls
updateCategory(category: buttonGroupType) {
this.calculatedForm.controls['category'].patchValue(category.name);
}
but my requirement is to bind using formcontrolName instead of using the methods. is it possible to avoid the update methods