Recently acquainted with Angular 4, I am currently working on integrating form validation messages in my application.
While the validation message displays as expected, I am facing an issue where the text field and label color do not change based on the state.
Here is the HTML code snippet I am using:
<form #AddressForm="ngForm" (ngSubmit)="SaveAddress(mAddress_Model)">
<div class="form-group" [class.has-error]="Name.invalid && Name.touched" [class.has-success]="Name.valid">
<label for="FName" class="control-label" >First Name *</label>
<input type="text" required minlength="4" id="Name" name="Name" class="form-control " [(ngModel)]="mAddress_Model.mFName" #Name="ngModel">
<div class="help-block alert-danger col-sm-12" *ngIf="Name.errors.required && Name.touched">
* First name is required
</div>
</div>
</form>
Despite using
**[class.has-error]="Name.invalid && Name.touched" [class.has-success]="Name.valid"**
, it does not seem to work for me, although the validation message div is functioning correctly.
I referred to a blog mentioned here:
I would appreciate any help or guidance on how to resolve this issue.