Get the value of radio button and store it , then show it

How to Get the value of radio button and store it , then show it ?

<div class="card">
     <div class="item item-image">
        <img src="img/Game-Img/Debug-img/level-1/{{question}}.png" id="question">
        <ul id="options">
          <li ng-repeat="option in options">
            <label class="item item-radio">
              <input  type="radio" name="answer" value="{{option}}"  required>
             <div class="item-content" >
               <i class="radio-icon ion-checkmark"></i>
        <button ng-click="checkAnswer()" class="button button-block button-stable" ng-show="answerMode">Submit Answer</button>

  .factory('questionFactory', function() {
        var questions = [
                question: "Q1",
                options: ["object", "main", "class", "case"],
                answer: "class"
                question: "Q2",
                options: ["println", "printf", "printline", "print"],
                answer: "println"
                question: "Q3",
                options: ["void", "void main", "static void", "static"],
                answer: "void"
                question: "Q4",
                options: ["println", "out", "system", "string"],
                answer: "out"

Check the angular help for examples -[radio] or u can use Ionic radio -

How about storing it ?

It will be store in variable that u defined in ng-model, which u must define in controller like:
in controller(i just seted default answers for every questions)
$scope.questions = {q1:‘object’, q2:‘println’, q3:‘void’, q4:‘println’ }
in html:
<input type="radio" ng-model="questions.q1" value="object"> <input type="radio" ng-model="questions.q1" value="main"> <input type="radio" ng-model="questions.q1" value="class"> <input type="radio" ng-model="questions.q1" value="case">

here is plunker

1 Like

Wow , Thanks ! :smiley:
And how can I show it ?

<div ng-show="showRadioValues">
          How can I show the Radio Values Here ?

Look at example above