Angularjs 验证复选框

Angularjs 验证复选框,angularjs,validation,checkbox,Angularjs,Validation,Checkbox,如何验证此复选框,必须至少选中一个复选框,如果没有,则必须有一些消息或警报 <div class="form-group" ng-class="{ 'has-error' : actionsAddForm.active.$invalid && !actionsAddForm.active.$pristine }"> <label class="control-label col-sm-2">Days*</label> <d

如何验证此复选框,必须至少选中一个复选框,如果没有,则必须有一些消息或警报

<div class="form-group" ng-class="{ 'has-error' : actionsAddForm.active.$invalid && !actionsAddForm.active.$pristine }">
    <label class="control-label col-sm-2">Days*</label>
    <div class="col-sm-10">
        <label>Monday
          <input type="checkbox" ng-model="actions.value1">
        </label>
        <label>Tuesday
          <input type="checkbox" ng-model="actions.value2">
        </label>
        <label>Wednesday
          <input type="checkbox" ng-model="actions.value3">
        </label>
        <label>Thursday
          <input type="checkbox" ng-model="actions.value4">
        </label>
        <label>Friday
          <input type="checkbox" ng-model="actions.value5">
        </label>
        <label>Saturday
          <input type="checkbox" ng-model="actions.value6">
        </label>
        <label>Sunday
          <input type="checkbox" ng-model="actions.value7">
        </label>
    </div>

日子*
星期一
星期二
星期三
星期四
星期五
星期六
星期日
这可以通过以下方式完成:

<div ng-hide="actions.value1 || actions.value2 || actions.value3...">
    You have an error 
</div>

你有一个错误

否则,如果您希望能够使用$valid,。。。您必须创建一个从ngModelController继承的自定义指令,并在其中添加自定义验证器:

好的,这是最基本和最有效的解决方案,thx,现在我就这样离开它,开始使用自定义指令