I'm looking to initialize certain form fields on a form and then call a function that has a if(this.form.valid) condition on it.
on the ngOnInit function I have an API call that gets some basic info and fills it on the form:
ngOnInit(){
this.apiService.getInfo(this.user.id).subscribe(
userInfo => {
this.formModel.fieldA = userInfo.A;
this.formModel.fieldB = userInfo.B;
this.formModel.fieldC = userInfo.C;
this.doStuff();
}
);
}
However when calling this.doStuff() the form is invalid, even though there are no errors and clicking on the submit button seems to force the validation and causes it to be valid.
Is there a way I can manually trigger the form's validation so that valid becomes true?
Edit: Stackblitz.

this.form.updateValueAndValidity()