Which attribute can be added to a form control to make it required?
- [ngRequired]
- [required]
- [validate]
- [isRequired]
In template-driven forms, the [required] attribute can be added to a form control to make it required. When this attribute is present on an input element, the user must fill in the control before submitting the form. It's a simple way to implement basic form validation for mandatory fields. The other options are not standard attributes for making form controls required in Angular template-driven forms.
Loading...
Related Quiz
- For creating a custom structural directive in Angular, the directive class should implement the _____ method.
- Imagine you're building a custom tooltip directive in Angular. To ensure that the tooltip is positioned relative to the element it's attached to, you need to gain access to the host element. How would you achieve this?
- Why would you use the ViewContainerRef in Angular?
- For projecting content into multiple designated spots within a component's template, you'd use multiple ______ tags with select attributes.
- You notice that a particular component in your application re-renders too often, causing performance issues. What steps can you take to optimize it?