The GV
directive is a custom Angular directive that pairs error messages with form controls. It is used to display validation error messages for form controls defined within an Angular FormGroup
based on the validation rules specified in a model that extends from GVModel
. The directive is applied as an attribute to HTML elements representing form controls.
[GV]
(Model: GVModel)Description:
The [GV]
directive is used to associate a model that extends from GVModel
with the form controls within an Angular FormGroup
. The model provides the validation rules for the form controls, such as maximum length, minimum length, and required fields.
Input Type:
Model - A class that extends from GVModel
.
Usage:
htmlCopy code
<form [GV]="GVUserModel" [formGroup]="form">
<!-- Form controls and error messages -->
</form>
The gv-error-message
elements are used to display error messages associated with specific form controls.
<gv-error-message>
Description:
The <gv-error-message>
element displays the error message associated with a specific form control. The name of the form control is provided as an attribute value to pair the error message with the correct form control.
Attributes:
name
(string): The name of the form control for which the error message is to be displayed.Usage:
htmlCopy code
<div>
<input type="text" formControlName="firstName">
<gv-error-message name="firstName"></gv-error-message>
</div>