In template-driven forms, which directive is used to conditionally apply CSS classes based on control validity?
- *ngFor directive.
- *ngIf directive.
- *ngTemplateOutlet directive.
- ngClass directive.
The ngClass directive is used in template-driven forms to conditionally apply CSS classes based on the control's validity state. You can use it to style form controls differently depending on whether they are valid, invalid, or untouched. The other directives listed serve different purposes and are not specifically designed for controlling CSS classes based on form control validity.
Loading...
Related Quiz
- In multi-slot content projection, how can you differentiate between the different content slots?
- What is the purpose of the ControlValueAccessor interface in Angular forms?
- A team is facing challenges with the application becoming slow as it grows. They are considering using ChangeDetectionStrategy.OnPush for all components. What considerations should they keep in mind?
- In the context of Reactive Forms, which property indicates the current value of the FormControl, FormGroup, or FormArray instance?
- For creating a custom structural directive in Angular, the directive class should implement the _____ method.