I have some reactive form like this:
this.form = this.formBuilder.group({
filter: [''],
filterReason: [''],
documentsRequired: [''],
urgencyReason: [''],
reportRequestedDate: [''],
urgencyDate: [''],
urgencyRemarks: ['']
});
And some value like this:
validation = false;
The problem I have is that i need to toggle value of that validation in html, and based on that if validation = true i need to add validation to some field that will look like this:
this.form = this.formBuilder.group({
filter: [''],
filterReason: [''],
documentsRequired: [''],
urgencyReason: [''],
reportRequestedDate: ['', Validation.required],
urgencyDate: ['', Validation.required],
urgencyRemarks: ['', Validation.required]
});
How to do that even i have init form on rendering the component?
updateValueAndValidityto make sure the new validators are run once they are set.