Hey everybody,
just want to uncheck the radio after selection without reloading the page. Tried to set $scope.choice=null; or something like that. But I can’t get it to work.
<ion-radio name="q_answer_{{current.id}}" ng-model="choice" ng-value="'a'"><span class="item-text-wrap" ng-if="current.option_a" ng-bind-html="current.option_a | strHTML"></span></ion-radio>
<ion-radio name="q_answer_{{current.id}}" ng-model="choice" ng-value="'b'"><span class="item-text-wrap" ng-if="current.option_b" ng-bind-html="current.option_b | strHTML"></span></ion-radio>
<ion-radio name="q_answer_{{current.id}}" ng-model="choice" ng-value="'c'"><span class="item-text-wrap" ng-if="current.option_c" ng-bind-html="current.option_c | strHTML"></span></ion-radio>
<ion-radio name="q_answer_{{current.id}}" ng-model="choice" ng-value="'d'"><span class="item-text-wrap" ng-if="current.option_d" ng-bind-html="current.option_d | strHTML"></span></ion-radio>
Help is very appreciated. Regards
Why do you want to uncheck the selected option after you select it
It’s a quiz. And after loading the next question the previous selected answer is initially checked. Right now I’m reloading the page after processing the given answer to have all radio’s unchecked.
where is the code for your onclick event where after you select and go to the next screen
Click button
<button ng-if="choice" class="button button-assertive" ng-click="check_choose(choice)">Confirm</button>
$scope.check_choose = function($choice){
$scope.correct_answers_text = "";
$ionicPopup.confirm({
title: title_of_confirm,
content: content_of_confirm
}).then(function(respon){
if(respon){
if($choice === $scope.current.answer){
$scope.current.congrats_icon = icon_for_true;
$scope.current.congrats_text = text_true;
$scope.correct_answers++;
//localStorage.setItem('quizCorrect',$scope.correct_answers);
}else{
var getvar = $scope.current.answer ;
$scope.correct_answers_text = $scope.current[opt[getvar]] ;
$scope.current.congrats_icon = icon_for_false;
$scope.current.congrats_text = text_false;
$scope.wrong_answers++;
//localStorage.setItem('quizWrong',$scope.wrong_answers);
}
$scope.modal_congrats.show();
$timeout(function(){
if($scope.current_index == ( data_inshape_quizs.length -1) ){
$scope.update_score();
$scope.modal_score_open();
}else{
$scope.current_index++;
//localStorage.setItem('quizIndex',$scope.current_index);
$scope.update_question();
$scope.update_score();
}
$scope.modal_congrats.hide(); //after hiding, the new question will be shown
}, 2500);
}
});
};