I have explored various solutions using ng-dblclick, $event, etc, but none of them seem to work for me.
Within a table, I have two radio buttons inside an ng-repeat. I have a field that determines which radio button should be active. While using ng-change works well for this purpose, I also want to be able to deselect any of the radio buttons. However, ng-change does not trigger in this case, so I added ng-click as well. The code below is functional, but I am curious if there is a cleaner way to achieve this.
<td>
<div class="inline-group">
<label class="radio">
<input type="radio" name="stage{{$index}}" ng-change="save(item, false)" ng-click="save(item, true)" ng-model="item.Stage" value="Started">
<i></i> Started
</label>
<label class="radio">
<input type="radio" name="stage{{$index}}" ng-change="save(item, false)" ng-click="save(item, true)" ng-model="item.Stage" value="Completed">
<i></i> Completed
</label>
</div>
</td>
Controller
var runOnce = false;
$scope.save = function (item, uncheck) {
if (runOnce) {
return;
}
if (uncheck) {
item.stage = null;
}
else {
runOnce = true;
}
...
.$promise.then(function (result) {
...
runOnce = false;
...
});
...