我正在尝试根据student.ispresent
显示我的复选框作为检查,但它不起作用,即checked
与ng-checked
不一致。
<div class="col-sm-6" ng-repeat = 'student in vm.students'>
<div class="form-group">
<label class="control-label col-sm-6">
{{student.name}}{{student.ispresent}}
</label>
<div class="btn-group col-sm-6" data-toggle="buttons">
<label class="btn btn-white" ng-click="vm.checkValues(student.id,'Yes')">
<input type="radio" name="" value="" autocomplete="off" ng-checked="student.ispresent ==='Yes' "> Yes
</label>
<label class="btn btn-white" ng-click="vm.checkValues(student.id,'No')">
<input type="radio" name="" value="" autocomplete="off" ng-checked="student.ispresent ==='Yes' "> No
</label>
</div><!--btn-group col-sm-6-->
</div><!--form_group-->
</div><!--//col-sm-6-->
答案 0 :(得分:1)
您错过了在复选框控件中设置ng-model
<label class="btn btn-white" ng-click="vm.checkValues(student.id,'Yes')">
<input type="radio" name="" value="" autocomplete="off" ng-model="StudentYes" ng-checked="student.ispresent ==='Yes' "> Yes
</label>
<label class="btn btn-white" ng-click="vm.checkValues(student.id,'No')">
<input type="radio" ng-model="StudentNo" name="" value="" autocomplete="off" ng-checked="student.ispresent ==='Yes' "> No
</label>
并请ng-click event
而不是check box
label
答案 1 :(得分:1)