I was given a requirement that all radio buttons across our site need to be unselectable. I can manage to do this with a function hardcoded to that set of radio buttons. But I would prefer to have a generic one so I don't have to add the same lines of code over and over.
Here's is my attempt to create a generic one. It seems to almost work in that it detects when the radiobutton should be cleared (I logged in the console) but it does not actually clear anything.
$scope.RadioCheckUncheck = function (RadioModel, event) {
if (RadioModel === event.target.value) {
console.log('looks like you clicked this already')
RadioModel = null;
}
}
and HTML
ng-click="RadioCheckUncheck(myModelName, $event)"
http://plnkr.co/edit/HcMfXWTtIRT9WThxE3c5?p=preview
Here is a similar version that works, but it's hardcoded.