如何设置复选框模型值的基础上选择的 [英] How to set checkbox selected on the basis of model value
本文介绍了如何设置复选框模型值的基础上选择的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个复选框,该复选框的值固定为'A'。我想选中该复选框如果模型值和值复选框属性相匹配。
I have a checkbox and the value of this checkbox is fixed as 'A'. I want the checkbox selected if the model value matches with checkbox value attribute.
<div class="form-horizontal">
<label class="col-md-2">
<input type="checkbox" id="Animals" name="Animals" ng-model="ModelData.Animals" value="A" /> Animal(s)
</label>
</div>
但使用上述code,选中复选框不会自动工作。我怎样才能做到这一点?
But using the above code, checkbox selection is not working automatically. How can I achieve this?
推荐答案
请,尝试使用: NG-检查=ModelData.Animals =='A'
关于NG-检查的更多信息:
http://docs.angularjs.org/api/ng.directive:ngChecked
More information about ng-checked: http://docs.angularjs.org/api/ng.directive:ngChecked
这篇关于如何设置复选框模型值的基础上选择的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文