I'm unclear on when and where exactly I should be calling the updateValueAndValidity.
Let's say I have a formGroup with many formControls. Now, based on some radio option selection an event fires to modify the 'validators' for several formControls.
Q1: Am I to call updateValueAndValidity immediately after modifications or after all modification calls have been done?
Q2: Am I to update the formGroup / formControls via the form to update all formControls
this.form.updateValueAndValidity('emitEvent': false);
or call each formControls individually
this.form.get('control1').updateValueAndValidity('emitEvent': false);
this.form.get('control3').updateValueAndValidity('emitEvent': false);
this.form.get('control8').updateValueAndValidity('emitEvent': false);
You need to call the update on all controls to be safe
In this answer https://stackoverflow.com/a/54045398/13680115 You can see the line that this function (
updateValueAndValidity) updates the parentNote the line It doesn't go down the tree, only up so if you call the function on the
form, thecontrolsmay not have the desired behavior but updating the controls will be reflected on the formSo as cumbersome as it maybe, you will need to update each controls' value and validity