Angularjs nested form input validation ng-repeat -
i want build nested form using ng-repeat following. since input fields required, want add error message in next line this: <span ng-show="submitted && editableform.[e.name].$error.required" class="error">required field</span>
, know wrong "editableform.[e.name].$error.required", right way this?
update tried adding <ng-form name="rowform">
, works when use hardcode name attribute, in case dynamically generated in [e.name]
thanks leo
nested form
<form name="editableform" novalidate="novalidate"><div class="neweditable"> <ul ng-repeat="row in newrows"> <li ng-repeat="e in rowattrs"> <input type="text" ng-model="newrows[e.name]" name="e.name" ng-required="e.required"> </li> <li><a href="" ng-click="rm_row($index)">x</li> </ul> </div><a href="" ng-click="newrow()">{{add}}</a> <a ng-show="newrows.length > 0" ng-click="saveit(editableform)">{{save}}</a> </form>
for specific code example need add ng-form
attribute first ng-repeat
:
<ul ng-repeat="row in newrows" ng-form="innerform">
you can similar original solution highlight required field:
<div class="validation_error" ng-show="e.required && innerform['\{\{e.name\}\}'].$error.required"> required </div>
Comments
Post a Comment