When creating a custom async validator for a form control, which type should the validator return to indicate a validation error?
- Boolean
- Number
- Observable
- String
When creating a custom async validator for a form control in frameworks like Angular, the validator should return an Observable to indicate a validation error. This allows you to handle asynchronous validation, such as making HTTP requests to validate the input. Observables provide a convenient way to handle async operations and emit error values when validation fails. Using other types like numbers, strings, or booleans would not be suitable for asynchronous validation scenarios.
Loading...
Related Quiz
- How can you share a service instance between multiple lazy-loaded modules in Angular?
- Which option is NOT a valid view encapsulation mode in Angular?
- The ng build command, by default, creates the output in the dist/______ directory.
- In Angular's dependency injection, what is the difference between a service provided in 'root' and one provided in a module?
- In template-driven forms, the ______ directive is used to bind an input field to a property in the component's class.