angularJS中ng-ng-repeat里的单选框(radio)和多选框(checkbox)赋值取值
HLML代码 多选
<div class="hy-checkk hlyw-fg-pandect-l"> <input type="checkbox" ng-model="x.checked" ng-change="selectOne()"/> <label class="abs-cell"></label> </div>js代码 全选和取消
$scope.cancelAllT = function () { angular.forEach($scope.dataDYWSB, function (i) { i.checked = true; }); }; $scope.cancelAllF = function () { angular.forEach($scope.dataDYWSB, function (i) { i.checked = false; }); };多选框取值
sum=true; $scope.dataHT=''; angular.forEach($scope.dataDYWSB, function (i) { if(i.checked){ if(sum){ $scope.dataHT= $scope.dataHT+'{"xsDvId":'+ i.xsDvId+'}'; sum=false; }else { $scope.dataHT= $scope.dataHT+',{"xsDvId":'+ i.xsDvId+'}'; } } });HTML代码 单选
<div ng-repeat="x in dataDYWSB"> <div class="hlyw-dx-main"> <div class="hlyw-dx-main-l">是否检修</div> <div class="hlyw-dx-main-c"> <input type="radio" class="hy-radio" ng-model="x.jxFlag" value="Y"> 是</div> <div class="hlyw-dx-main-c"> <input type="radio" class="hy-radio" ng-model="x.jxFlag" value="N" > 否</div> </div> <div class="hlxnyyw-po-split-ss"></div> <div class="hlyw-dx-main"> <div class="hlyw-dx-main-l">是否到位</div> <div class="hlyw-dx-main-c"> <input type="radio" class="hy-radio" ng-model="x.dwFlag" value="Y"> 是</div> <div class="hlyw-dx-main-c"> <input type="radio" class="hy-radio" ng-model="x.dwFlag" value="N" > 否</div> </div> <div class="hlxnyyw-po-split-ss"></div> <div class="hlyw-dx-main"> <div class="hlyw-dx-main-l">是否完成</div> <div class="hlyw-dx-main-c"> <input type="radio" class="hy-radio" ng-model="x.doneFlag" value="Y" > 是</div> </div>
取值
console.log($scope.dataDYWSB); console.log(JSON.stringify($scope.dataDYWSB));