angularjs获取check框选中的值
html:
<div><input type="checkbox" ng-click="updateSelection($ity.id)" ng-checked="ity.id)">选择</div> js:
angular和angularjs$scope.selected = [];
$scope.updateSelection = function (event, id) {
var checkbox = event.target;
var action = (checkbox.checked ? 'add' : 'remove');
if (action == 'add' && $scope.selected.indexOf(id) == -1) {
$scope.selected.push(id);
}
if (action == 'remove' && $scope.selected.indexOf(id) != -1) {
var idx = $scope.selected.indexOf(id);
$scope.selected.splice(idx, 1);
}
console.log($scope.selected)
}
$scope.isSelected = function(id){
return $scope.selected.indexOf(id)>=0;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。