The ngMessage is like a switch case you need to pass the correct group to detect the error, when you create a form in angular he wraps the form by the name of the form and the name of your inputs for example:
<form name="myForm">
<input name="myInput">
<input name="myInput2">
<input name="myInput3">
</form>
Wrap to something like this with there repective $error each:
myform = {
myInput: {
$error:{
//...
}
},
myInput2: {
//...
},
myInput3:{
//...
},
//...
}
You are using the name of the form, and not contain the real error of each element (contains an array with all relevant data of each error), you must usage the name of input names like this plunkr:
http://plnkr.co/edit/I43HTQeWZS85N55hXGfF?p=preview
HTML:
<form name="setPlayersForm">
<div ng-repeat="player in players track by $index" class="name-input">
<div ng-init="player.form_name='player'+player.id" ></div>
<input type="text"
placeholder="Your Name"
ng-model="player.name"
name="{{player.form_name}}"
required/>
<ng-messages for="setPlayersForm[player.form_name].$error" ng-if="setPlayersForm[player.form_name].$touched">
<ng-message when="required" class="alert-box alert">This field is required</ng-message>
</ng-messages>
</div>
</form>
JS:
var app = angular.module('plunker', ['ngMessages']);
app.controller('MainCtrl', function($scope) {
$scope.players = [{
name: "jhon",
id:1
},
{
name: "jhon1",
id:2
},
{
name: "jhon2",
id:3
},
{
name: "jhon3",
id:4
}
];
});