我有一个复选框列表
<input type="checkbox" ng-model="servicesModel" value={{item.name}} id={{item.name}} ng-click="toggleSelection(item.name)"/>
我想取消选中选中的复选框
$scope.toggleSelection = function toggleSelection(id) {
window.alert("You can't select this !");
//deselect the selected checkbox
}
一切正常,但我找不到如何取消选择所选内容的方法。
传递模型并分配模型 false
<input type="checkbox" ng-model="servicesModel" value={{item.name}} id={{item.name}} ng-click="toggleSelection(item.name, servicesModel)"/>
$scope.toggleSelection = function toggleSelection(id, model) {
window.alert("You can't select this !");
//deselect the selected checkbox
model = false; //set
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句