I am using ReactiveFormsModule and have defined all my form controls including simple validators such as Validators.required
within a const configuration.
I
Looking at your code, what you could do:
Site is required?
Please enter a Site, eg. xyz.
Look at [formControl]="site_id_control"
Then, this way, you can add or remove the validators from that specific control like this:
inside your class:
export class JobSearchEditComponent {
private site_id_control=this.form.controls['site_id'];
updateValidator(){
let exisitingValidators = this.site_id_control.validators;
this.site_id_control.setValidators(Validators.compose([...existingValidators , exampleValidator]))
// you probably also need this :
this.site_id_control.updateValueAndValidity();
}
}