I got it all working fine, except one thing. I need myForm
to be $valid = true
if
and $valid = false
if
Note this is all inside an ng-repeat and an ng-form subform.
How would I do it? Is there any way?
Simply add the ng-required
directive to all fields in myForm
.
Eg <input type="text" name="myInput" ng-required="isRequired()" />
.
The isRequired
function should then simply return true if at least one of the form fields contains a value, otherwise false.
If this doesn't work, then there's information you've left out - so in that case please provide more information about your HTML and JS code (I'm only mentioning this because I see you've tagged the question with ng-repeat, which might make the scenario slightly different than the vanilla one you've described in your question).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.