I am trying to dynamically generate input fields using ng repeat in Angular, but I am encountering an issue where error messages only appear on the last element. How can I make these error messages apply to each individual element?
<form name="setPlayersForm">
<div ng-repeat="player in rp.KillerService.getPlayers() track by $index" class="name-input">
<input type="text"
placeholder="Your Name"
ng-model="player.name"
required/>
<a class="fa fa-trash-o" ng-if="player.newPlayer" ng-click="rp.removePlayer(player)"></a>
</div>
<ng-messages for="setPlayersForm.$error" ng-if="rp.submitted">
<ng-message when="required" class="alert-box alert">This field is required</ng-message>
</ng-messages>
</form>