I am wondering if there is any method to set value and update validity of a control of a form. Given the following:
this.updateForm = this._formBuilder.group({
user: ['',Validators.required]
});
I have some directive which has on change trigger, that triggers the following:
changeUserSelection(value){
this.updateForm.controls['user'].value = value // doesnt trigger validation?
}
And I am wondering how I can set the value, and trigger validation of this field. Doing this my way, doesnt trigger validation.
Thanks
You should use the updateValue
method instead:
changeUserSelection(value){
this.updateForm.controls['user'].updateValue(value);
}