Answer the question
In order to leave comments, you need to log in
How to check the validity of all forms on a page using angular?
There are several forms on the page that are created with ng-repeat and ng-form.
Within the scope of ng-repeat, checking the validity of the form is not a problem.
But how to check the validity of all these forms OUTSIDE of ng-repeat?
The situation is such that the user can dynamically add objects to the array, each object is a new form, in fact.
By clicking on the "Submit" button, there should be no invalid data. But how to make it inactive if at least one form is invalid?
Answer the question
In order to leave comments, you need to log in
PSEUDOCODE:
<div id="form-container">
<form ng-repeat="f in forms">
<input ng-model="f.title">
</form>
</div>
<input type="button" ng-click="submitForms('#form-container')">
function controller(){
var self = this;
self.submitForms = function(selector){
let formContainer = angular.element(selector);
let forms = formContainer.find('form');
// и проверяйте валидность форм
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question