2

I using radio button within my angular page. The radio button is under the ng-repeat. I want to check the radio default by the json data is true. Then if one radio checked, change the remaining data into be a false. i done it. But radio button is not checked in the UI.

Here a fiddle link

I Hope you understand this and what i need.

2 Answers 2

1

Change your $scope.setChoiceForQuestion to:

$scope.setChoiceForQuestion = function (q, c) {        
   angular.forEach(q, function (r) {
        if(c != r)
        r.isUserAnswer = false;
    });
};

And it should work.

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

Comments

1

use ng-checked="choise.isUserAnswer || choise.isUserAnswer === 'true'" for check and uncheck element instead of ng-model="choice.isUserAnswer" compare with 'true' because in json you have string. Or you can change json "true" and "false" to true and false without double quotes and leave in condition just ng-checked="choise.isUserAnswer".

Here a fiddle link

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.