我有一个复选框列表
<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
}
每件事情都运转良好,但我找不到如何取消选择所选的那个。
答案 0 :(得分:1)
传递模型并为其指定<v:textpath style=\"FONT: 8pt Tahoma; TEXT-DECORATION: none; v-text-align: center; v-rotate-letters: false; v-text-kern: true\" on = \"t\" string = \"HERE IS THE TEXT I WANT TO LINE BREAK\"></v:textpath>
false
答案 1 :(得分:0)
使用angular $ event更新控制器:
$scope.toggleSelection = function ($event, item) {
var checkbox = $event.target;
var action = (checkbox.checked ? 'add' : 'remove');
$scope.updateToggleSelection(action, item);
};
$scope.updateToggleSelection(action, item) {
if(action =='add') {
item = true;
}
if(action == 'remove') {
item = false;
}
}
在html中:
<input type="checkbox" ng-model="servicesModel" value={{item.name}} id={{item.name}} ng-click="toggleSelection($event, item.name)"/>