I have a list of form fields that are generated as the result of an ng-repeat
. As such I use the {{$index}} of the repeat loop to name the fields, i.e. ` which leads to:
<input name="myInput0">
<input name="myInput1">
<input name="myInput2">
...
etc. Now I'm trying to access the fields' $valid
attribute from the form in the standard angularjs way i.e. myForm.myInput{{$index}}.$valid
which resolves to e.g. myForm.myInput0.$valid
which I understand won't work because it's accessing a variable and numbers won't be allowed.
However I then tried to access it with myForm['myInput{{$index}}'].$valid
, e.g. myForm['myInput0'].$valid
which I thought might work but still doesn't. Is there any way possible to access the form field when it contains a numeral? (or other illegal char like a hyphen)?
e: I'm using angularjs 1.2 which might explain why this isn't working. Does anyone know of a workaround for pre 1.3 angular?