In an Angular reactive form, how can you dynamically add a validator to a form control at runtime?
- Create a new FormControl instance with the validator
- It's not possible to add validators at runtime
- Use the 'Validators' service
- Use the 'setValidators' method
To dynamically add a validator to a form control in an Angular reactive form, you should use the 'setValidators' method to set the validators for the form control, allowing you to change the validation rules at runtime.
Loading...
Related Quiz
- To programmatically navigate to a route with parameters, you use the _____ method of Angular's Router service.
- What is the impact of lazy loading on the initial load time of an Angular application?
- In a dynamic form, to validate data asynchronously on the server-side, you can use a custom _____ validator.
- What is the purpose of testing a custom directive in Angular?
- To handle errors within an Observable chain, you can use the _____ operator in RxJS.