Angular客户端验证特例

时间:2015-03-16 09:18:16

标签: angularjs

<input id="declarationAcknowledgement" name="declarationAcknowledgement" ng-false-value="false" ng-model="formData.declarationAcknowledgement" ng-true-value="true" type="checkbox" />

<label data-localize="I Agree" for="declarationAcknowledgement" >I Agree</label>

<div class="pw-form-inline-error" data-localize="Accept to proceed" ng-show="(peopleworksForm.declarationAcknowledgement.$dirty || peopleworksForm.submited)  && formData.declarationAcknowledgement != 'true'">Accept to proceed</div>

这是我设置的控制器中的视图侧&#34; Form.submited = true&#34;

我想要的是,如果用户选中复选框,如果值不等于&#39; true&#39;设置表单。$有效false从视图侧而不是在控制器中我该怎么做。任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:1)

你可以给required="required"复选框。

答案 1 :(得分:1)

试试这个..添加required="required"并制作ng-false-value=""

  <input required="required" name="declarationAcknowledgement" ng-false-value="" ng-model="formData.declarationAcknowledgement" ng-true-value="true" type="checkbox" />