I use the ng form as the parent form and the child mg forms for validation with ng-repeat.
<div ng-form="form"> <div ng-repeat="field in fields"> <div ng-form="subform"><input...></div> </div> </div>
And thus confirming:
if ($scope.form.subform.$invalid && !$scope.form.subform.$error.required) {
(this is a very simplified example, I have more different subforms for different types of input and with different names, for example, input [text] is called TextForm, input [numeric] is NumericForm, etc.)
Everything works as expected, if only on the field. But if ng-repeat generates several fields, the check runs only the last subform, others are ignored.
Is there a way to cycle through all the subforms to check if one of them is?
In addition, I check all the required fields blank:
if ($scope.form.$error.required) { angular.forEach($scope.form.$error.required, function (object, index) { $scope.form.$error.required[index].$setDirty(); } ); }
So, if my fields are executed as follows:
....ng-form="TextForm" ng-class="{ 'has-error': TextForm.$dirty && TextForm.$invalid }"....
And he marks all the subforms, even if there are many identical names with the same name.
Maybe I can do something similar with invalid fields? Although I tried a lot of things, nothing worked ...