I have this formgroup:
this.form = this.fb.group({
id: [],
active: [true],
name: [''],
});
and this submit form function:
onSubmit(submitForm: FormGroup) {
this.submitForm.controls['name'].setValidators([MyValidators.unique(`name`, () => {
return this.service.checkNameUnique(this.submitForm.value.name, this.labelFg.value.id);
})]);
}
I didn't set validation to the form when initiating because this form will only be validated after I clicked the submit button. So I use the setValidatorsfunction to set validation in onSubmit function.
But question is: How do I trigger this validation and get the validation result?