I am working on a project where I need to dynamically set a value for a formControl within a formGroup based on changes to another formControl in the same formGroup.
However, when I attempted to implement this, I encountered an error stating:
maximum call stack size exceeded angular
:
this.formGroup.get('DepreciationConfigInfo')
?.valueChanges.pipe(takeUntil(this.destroy$))
.subscribe((depreciationConfigInfo) => {
this.formGroup.get('DepreciationConfigInfo')
?.get('DepreciationEnd')?.setValue(5)
})
I am focusing on the FormGroup and trying to listen for changes to the DepreciationPeriod or DepreciationStart event:
DepreciationConfigInfo: new UntypedFormGroup({
DepreciationPeriod: new UntypedFormControl(),
DepreciationStart: new UntypedFormControl(),
DepreciationEnd: new UntypedFormControl({value: '', disabled: true}),
}),
Thank you for any assistance.