Crocsx
Crocsx

Reputation: 7609

Uncheck a RadioBox angularJS

I am using angularJS and Mat-Design for angularJS.

I have a big form with a md-radio-group like this

https://codepen.io/anon/pen/VVVLVe

I use radio because I want to select 1 field MAXIMUM but also NO FIELD is possible.

But, If I select something, It's impossible to unselect the value even tho I set the model to null.

  $scope.clickStatus = function(val){
    console.log(val, $scope.data.group1)
    if(val === $scope.data.group1){
      $scope.data.group1 = null
    }
  }

the checkbox keep being set and the index and value are still set.

How can i uncheck that radio box ?

Upvotes: 1

Views: 47

Answers (1)

TabsNotSpaces
TabsNotSpaces

Reputation: 1357

Like mentioned in comments, I would suggest using md-checkbox instead. You can uncheck all other checkboxes in the method you tie to ng-click

Upvotes: 1

Related Questions