我在表中有以下输入:
<input type="checkbox" name="slection" ng-click="addEntryToSelection(entry)" value="{{entry.defaultName}}">
如何获取哪些项目被选中并在单击按钮后获取其值,或者如果选中,如何将值添加到数组中并在取消选中后删除?
感谢您的帮助。
最佳答案
你可以这样做。
<input type="checkbox" name="slection" ng-click="addEntryToSelection(entry)" value="{{entry.defaultName}}" ng-model="toggleInfo.checked" ng-change="toggleChange">
在 Controller 中。
function toggle(){
console.log('check!');
}
var change = ($scope.toggleChange==true ? toggle() : /*false*/);
//persist the check value where you could assign to services;
if ($scope.toggleChange==true){
$scope.toggleInfo = { checked: true };
} else {
$scope.toggleInfo = { checked: false };
}
关于javascript - Angular JS - 如何将选中的输入添加到数组中以及如何在取消选中后删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27462154/