AngularJS: SetValidity in ng-repeat fields -
i have form generates fields using ng-repeat. want attach each independent field set validity in case left empty. there way this?
thanks!
you need utilize ng-form ng-repeat. i'd update example, didn't give me one... thought this:
<form name="myform"> <div ng-repeat="item in items" ng-form="repeatform"> <input type="text" name="foo" ng-model="item.foo" required/> <span ng-show="repeatform.foo.$error.required">required</span> </div> </form> if needed access 'setvalidity' on model reason, you'd have pass repeatform.foo function either on controller or on scope. ng-click="myweirdvalidationfunction(repeatform.foo)". there's not much of utilize case though.
angularjs angularjs-ng-repeat angularjs-ng-form
No comments:
Post a Comment