Which directive in template-driven forms is used to display specific error messages based on validation failures?
- *ngFor directive.
- *ngIf directive.
- *ngSwitch directive.
- *ngTemplateOutlet directive.
In template-driven forms, the *ngIf directive is used to conditionally display error messages based on validation failures. You can use it to check the control's validity and display custom error messages as needed. The other directives listed have different purposes and are not typically used for displaying validation errors in template-driven forms.
Loading...
Related Quiz
- In Angular's hierarchical dependency injection, the _____ is the first injector that is checked when trying to resolve a service dependency.
- Which method is used to add a new control to a FormGroup in reactive forms?
- When you want to get only the first emitted value from an Observable and then complete, you should use the ________ operator.
- When using ChangeDetectionStrategy.OnPush, Angular relies on ________ checks to determine component updates.
- Which command in Angular CLI generates a new service?