AngularJS relies on input names to detect validation errors.
Unfortunately, today it is impossible (without using the user directive) to dynamically generate an input name. Indeed, checking the input documents, we can see that the name attribute accepts only a string.
, ng-form . - :
<div ng-repeat="variant in variants" >
<ng-form name="innerForm">
<div>
<label>Duration:</label>
<input name="duration" ng-model="variant.duration" required />
<span ng-show="innerForm.duration.$error.required">Duration required</span>
</div>
<div>
<label>Price:</label>
<input name="price" ng-model="variant.price" required/>
<span ng-show="innerForm.price.$error.required">Price required</span>
</div>
</ng-form>
UPDATE: , - :
<input type="hidden" name="variants[{{$index}}][duration]" ng-model="variant.duration"/>
<input name="duration" ng-model="variant.duration" required />
, , ( ). , .
PS: , . ng-submit