Reputation: 803
I am new to Angular and I have a Reactive Forms with AbstractControl
that subscribe for valueChange
to listen for any values change in input field. Inside the subscribed function I want to change the value of the input under a certain condition.
this.abstractControl.valueChanges.subscribe(data => {
...
if(.....) {
this.formGroup.patchValue({
name: result
)}
}
...
}
I tried to use this.abstractControl.setValue(result)
does'nt work too.
I get an error in setting the value.
ERROR RangeError: Maximum call stack size exceeded
What is the recommended way of listening to a value change and changing the value accord to a condtion?
Upvotes: 6
Views: 13223
Reputation: 803
@jonrsharpe thanks. Problem resolved with emitEvent: false
.
Read: angular.io/api/forms/FormControl#setValue
Upvotes: 15