核心提示:单选框labelinput type=radio name=selectType ng-model=selectType value=0span class=radio ng-class={radio...
单选框
<label> <input type="radio" name="selectType" ng-model="selectType" value="0"> <span class="radio" ng-class="{radioActive: selectType == 0}"> <span class="radio-o" ng-if="selectType == 0"></span> </span> <span class="label-text simsun" ng-class="{active: selectType == 0}">制作问题</span> </label> <label> <input type="radio" name="selectType" ng-model="selectType" value="1"> <span class="radio" ng-class="{radioActive: selectType == 1}"> <span class="radio-o" ng-if="selectType == 1"></span> </span> <span class="label-text simsun" ng-class="{active: selectType == 1}">审核问题</span> </label>
获取选中值:
$scope.selectType // 即input 的value
复选框:
思路:
// 因为项目中需要一键全选 <!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="utf-8"> <script src="https://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-controller='myCtrl'> <p>My cars:</p> <label ng-repeat='i in boxList'> <input type="checkbox" ng-checked="all" name='checkbox1' > <span>{{i}}</span> <span>{{}}</span> </label> <p>点击 "Check all" 选择所有的车。</p> <button ng-click='ss()'>dddd</button> <script> angular.module('myApp', []).controller('myCtrl', ['$scope', function($scope) { $scope.boxList = ['Volvo', 'Ford', 'Mercedes']; $scope.ss = function() { const s = document.querySelector('input[name=checkbox1]'); console.log(s.checked) } }]) </script> </body> </html>
上面通过 ng-model 绑定一个值,然后 其他通过ng-checked 再绑定这个值,提交获取document.querySelector(‘input[name=checkbox1]’).checked;