仅当满足特定条件时,我才需要对表单字段应用验证。假设我有这样的表格:
<div ng-controller="MyController">
<form name="myForm">
<div>
<div class="" ng-class="{error: myForm.gender.$invalid}">
Gender:
</div>
Male <input type="radio" name="gender" value="M" ng-model="survey.gender" required/>
Female <input type="radio" name="gender" value="F" ng-model="survey.gender" required/>
</div>
<div ng-show="survey.gender == 'F'">
<div class="">
Are you pregnant?
</div>
Yes <input type="radio" name="pregnant" value="Y" ng-model="survey.pregnant"/>
No <input type="radio" name="pregnant" value="N" ng-model="survey.pregnant"/>
</div>
</form>
</div>
我只想在用户选择女性时才提出怀孕问题。Angular 是否为此提供了任何类型的验证?