我有像这样的HTML代码
<div class="section1">
<div ng-repeat="item in Objs1">
<ng-form name="myForm">
<input require name="expression" ng-model="item.exp" />
<label ng-show="myForm.expression.$error.required" class="error">*-required</label>
</ng-form>
</div>
<button ng-disabled="--if any myForm is invalid--">Add</button>
</div>
<div class="section2">
<input require name="first" ng-model="firstName" />
<input require name="first" ng-model="SecondName" />
</div>
我怎么知道--if any myForm is invalid--
?
答案 0 :(得分:2)
ngForm可以嵌套。只需添加外部ngForm:
<ng-form name="parentForm">
<div ng-repeat="item in Objs">
<ng-form name="myForm">
<input require name="expression" ng-model="item.exp" />
<label ng-show="myForm.expression.$error.required" class="error">*-required</label>
</ng-form>
</div>
<button ng-disabled="parentForm.$invalid">Add</button>
</ng-form>