取消选中AngularJS中的复选框时重置单选按钮

时间:2017-04-30 14:18:15

标签: angularjs checkbox radio-button

example

在上面的示例中,选中复选框后,复选框下方的单选按钮将被激活。取消选中此复选框时,我想重置单选按钮(以便不填充单选按钮)。



<div class="checkbox checkbox-info">
  <input id="icb" type="checkbox" ng-model="checked">
  <label for="icb"><i class="fa fa-refresh">&nbsp;</i><b>Integratie</b></label>
</div>
<div class="radio">
  <input type="radio" name="irb" id="iarb" ng-disabled="!checked" value="!checked">
  <label for="iarb">Administrator</label>
</div>
<div class="radio">
  <input type="radio" name="irb" id="imrb" ng-disabled="!checked" value="!checked">
  <label for="imrb">Medewerker</label>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

将单选按钮value更改为ng-model

HTML

<div class="checkbox checkbox-info">
      <input id="icb" type="checkbox" ng-model="checked" ng-click="onCheck()">
      <label for="icb"><i class="fa fa-refresh">&nbsp;</i><b>Integratie</b></label>
</div>

    <div class="radio">
      <input type="radio" name="irb" id="imrb" ng-model="radio_checked" value="1" ng-disabled="!checked" />

      <label for="iarb">Administrator</label>
    </div>
    <div class="radio"> 
    <input type="radio" name="irb" id="imrb" ng-model="radio_checked" value="2" ng-disabled="!checked" />

      <label for="imrb">Medewerker</label>
    </div> 

JS

$scope.onCheck = function(){
    $scope.radio_checked = false;    
 }

Demo Fiddle