I have to do form validation for multiple forms which have to be created dynamically. I have created the forms dynamically by using ng-repeat but I am not able to access that form in controller.
Please check the code:
<button ng-click="navigate()">Next</button>
<div ng-repeat="service in services">
<ng-form name="mainform">
<div ng-repeat="spec in service.products">
<ng-form name="subform">
<input type="text" name="{{spec.name}}" ng-model="spec.value">
<span ng-show="subform[spec.name].$invalid">please enter</span>
</ng-form>
</div>
</ng-form>
</div >
It is working fine, but I need to check whether at least one of mainform's subforms is valid or not after clicked on next button so I have tried to access this in controller like this:
$scope.navigate=function(){
console.log($scope.mainform.subform);
console.log($scope.subform);
}
but I am getting undefined
for both console logs. How can I access multiple dynamically created forms in the controller?