I want to generate inputs with ng repeat, the problem is when i have an error this is only apply on the last element, how can i make this apply per element?
<
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:
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:
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
}
];
});