0

My function:

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

Here's my plunker : http://plnkr.co/edit/g1t4pludTTIAJYKTToCK?p=preview

I wan't to uncheck radio button after click on it. My code works with normal radio, but not with ui.bootstrap. Thanks for asnwers in advance!

11
  • Your code in the plunker doesn't show any check box. Kindly fix it then probably I will get a better idea as to where the issue is. Commented Aug 11, 2017 at 6:36
  • The plunker is changed but there is still no radio button in it. Commented Aug 11, 2017 at 6:51
  • Why do you need a radio button for this? if you only have to toggle between 2 states, why not use a check box. Commented Aug 11, 2017 at 6:53
  • plnkr.co/edit/GWKVrMxYEL9QhdwJIVUA?p=preview Commented Aug 11, 2017 at 6:53
  • @GopalkrishnaNarayanPrabhu Here is btn-radio from bootstrap Commented Aug 11, 2017 at 6:54

1 Answer 1

1

I guess this is what you need:

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>

Changes:

  1. You don't have to bind a method on click.
  2. Upgrade your bootstrap-tpls lib to ver 2.5.0
  3. Use proper element name for bootstrap radio button. which is uib-btn-radio
  4. Use uncheckable attribute of uib-btn-radio, to make that radio button un-check-able

updated plnkr here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.