2017-08-11 57 views
-2

我的功能:取消选中单选按钮角UI,引导

$scope.DownloadedUncheck = function (event) { 
    if (event.target.value === lastChecked) { 
     delete $scope.$parent.selectedDownloaded 
     lastChecked = null 
    } else { 
     lastChecked = event.target.value 
     delete $scope.$parent.selectedDownloading 
    } 
}; 

这里是我的plunker:http://plnkr.co/edit/g1t4pludTTIAJYKTToCK?p=preview

我wan't点击它后取消单选按钮。 我的代码适用于普通收音机,但不适用于ui.bootstrap。 感谢提前asnwers!

+0

你在plunker码不显示任何复选框。请修复它,那么我可能会更好地了解问题所在。 –

+0

重新调整,但仍然没有单选按钮。 –

+0

为什么你需要一个单选按钮?如果您只需在2个状态之间切换,为什么不使用复选框。 –

回答

0

我想这是你所需要的:

HTML:

<body ng-controller="FirstCtrl"> 

    <label class="btn btn-default" uib-btn-radio="'True'" ng-model="$parent.selectedDownloaded" uncheckable>Downloaded 
     </label> 
    <br /> 
    <label class="btn btn-default" uib-btn-radio="'False'" ng-model="$parent.selectedDownloaded" uncheckable>To Download 
     </label> 

    <table class="table table-striped table-bordered table-hover"> 
     <thead> 
      <tr> 
       <th>#</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr ng-repeat="name in name | filter:{Download:selectedDownloaded}"> 
       <td>{{name.Download}}</td> 
      </tr> 
     </tbody> 
    </table> 
</body> 

变化:

  1. 您不必绑定在点击的方法。
  2. 将bootstrap-tpls库升级到版本2.5.0
  3. 对引导程序单选按钮使用正确的元件名称。这是uib-btn-radio
  4. 使用的uib-btn-radio属性,以使该单选按钮,取消选中,能够

updated plnkr here