如果存在条件,则需要取消选中列表中的复选框 [英] Need to uncheck checkbox in list if condition exists
本文介绍了如果存在条件,则需要取消选中列表中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我之前问过一个相关的问题:
I previously asked a related question:
这对于一个复选框来说很好,但是现在我有了一个列表:
This is fine for one checkbox but now I have a list:
<tr ng-repeat="part in partstoorder">
<td>
<input type="checkbox"
ng-change="change(ordered, $index, part)"
ng-true-value="1"
ng-false-value="0"
ng-model="ordered"
ng-checked="checkedStatus"
name="part-ordered" />
</td>
</tr>
JS:
$scope.change = function(value, part_index, part) {
var part_id = part.id,
vehicle_id = part.vehicle_id,
ordered_from_val = part.ordered_from;
if (modal_hidden_event) {
$scope.checkedStatus = false;
}
}
我如何只取消选中当前复选框?
How would I go about only unchecking the current checkbox?
推荐答案
仅使用数组
<tr ng-repeat="part in partstoorder">
<td>
<input type="checkbox"
ng-change="change(ordered, $index, part)"
ng-true-value="1"
ng-false-value="0"
ng-model="ordered"
ng-checked="checkedStatus[$index] = true"
name="part-ordered" />
</td>
</tr>
JS
$scope.checkedStatus = [];
$scope.change = function(value, part_index, part) {
var part_id = part.id,
vehicle_id = part.vehicle_id,
ordered_from_val = part.ordered_from;
if (modal_hidden_event) {
$scope.checkedStatus[part_index] = false;
}
}
这篇关于如果存在条件,则需要取消选中列表中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文