将 HTML5“必需”属性用于无线电类型输入和 Angularjs 表单验证时,我得到了奇怪的结果
我的输入:
<form name="myForm">
<div ng-repeat="i in [0,1,2]">
<input type='radio' name='var1' ng-model='var1' value='1' required />1<br />
<input type='radio' name='var1' ng-model='var1' value='2' required />2<br />
<input type='radio' name='var1' ng-model='var1' value='3' required />3<br />
<span ng-show="myForm.var1.$error.required" ng-click="">Choose an option.</span>
<button ng-disable="myForm.$invalid">Submit</button>
</div>
</form>
当我选择一个选项时,其他选项将被取消选择。此外,两者的表单验证都被激活/停用。