angularjs - issue when set parent form valid manually by setting each child form field valid -


i have nested , repeated forms on ui.

<form class="form-horizontal" name="registration">   <form ng-repeat = "s in students" name="studentregisteration">      <input type="number" id="input" name="input" model="input" ng-change="validate()">   </form> </form> 

i trying $setvalidity() specific field of child form following

$scope.validate = function (index) {     if (condition true)      $scope.registration.studentregisteration.input.$setvalidity('integer', false); } 

it works fine until have 1 form on ui i.e. set integer (property) valid , parent forms become valid.

it not work when have multiple forms on ui... parent forms not become valid... not sure how set field valid individual child form parent becomes valid.

any idea?

i think if pass form controller in function parameter validate work. like

<form class="form-horizontal" name="registration">   <form ng-repeat = "s in students" name="studentregisteration">      <input type="number" id="input" name="input" model="input" ng-change="validate(registration.studentregisteration)">   </form> </form> 

code:

$scope.validate = function (form) {     if (condition true)      form.input.$setvalidity('integer', false); } 

i not sure if pass registration.studentregisteration or studentregisteration, try both


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -