Angular.js至少需要一个复选框 [英] Angular.js required at least one checkbox
本文介绍了Angular.js至少需要一个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果这是重复的话我不会感到惊讶,但是我找不到任何简单的东西。
I wouldn't be surprised if this is a duplicate however I can't find anything simple along the lines of what I need.
我只需要的是用户需要选择至少一个复选框,但我很困惑如何完成此操作。
All I need is the user to be required to choose at least one checkbox but I'm baffled how to accomplish this.
<input type="checkbox" ng-model="myForm.first" /> First <br />
<input type="checkbox" ng-model="myForm.second" />Second <br />
<input type="checkbox" ng-model="myForm.third" /> Third
推荐答案
<input type="checkbox" ng-model="myForm.first" ng-required="myForm.first || myForm.second || myForm.third" /> First <br />
<input type="checkbox" ng-model="myForm.second" ng-required="myForm.first || myForm.second || myForm.third"/>Second <br />
<input type="checkbox" ng-model="myForm.third" ng-required="myForm.first || myForm.second || myForm.third"/> Third
这篇关于Angular.js至少需要一个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文