Reputation: 506
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
Upvotes: 2
Views: 210
Reputation: 26940
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>
Upvotes: 2