2

I am trying to add red frame to a field in a form in angular.
When working with static fields (not populated with ng-repeat) everything is working good. When the field is created with ng-repeat looks like the ng-class that uses the current index is not working. The form state is correct but the class with the red frame is not added to the field.

See this Plunker: http://plnkr.co/edit/hDfTHY?p=preview When adding a value to all input fields the button become enabled. However, only first input is red when empty.

Thanks

Roi Ezra
  • 506
  • 1
  • 5
  • 11

1 Answers1

2

One option is to add inner form:

<div ng-form="nested" class="col-md-4" ng-class="{'has-error': nested.item.$invalid}">
     <input type="text"
            ng-model="item"
            class="form-control"
            name="item"
            id="item{{$index}}"
            required ng-minlength="2">
</div>

See this question

Community
  • 1
  • 1
karaxuna
  • 26,752
  • 13
  • 82
  • 117