Within my AngularJS form, I successfully implemented validation for an email field. However, upon adding another email field, the validation applies to all items. My intention is for only the first field to be validated as required.
<form novalidate name="myForm">
<button class="btn btn-info btn-sm" ng-click="addNewChoice('email')">
<i class="fa fa-at"></i> Add Email
</button>
<br>
<div class="form-group row">
<div data-ng-repeat="email in emails">
<div class="col-md-4 col-sm-12" ng-class="{
'has-error' :isInputInvalid(myForm.email1),
'has-success' : isInputValid(myForm.email1)
}">
<label for="email{{ $index + 1}}">Email {{ $index + 1}}</label>
<input type="email" class="form-control" name="email{{ $index + 1}}" ng-model="formModel.emails[$index + 1]" id="email{{ $index + 1}}" placeholder="Enter email" required>
<span class="help-block" ng-show="myForm.email1.$error.required && myForm.email1.$dirty">Required</span>
<span class="help-block" ng-show="myForm.email1.$error.email">Email not valid!</span>
</div>
</div>
</div>
</form>