title: Angular2,Typescript: How to put the radio button checked when in an array which displays one element per page?
body: <p>Let me explain it in detail.Sorry for the question framing.</p>
  
  <p>I've an array of Objects which is stored in the REST API. That array contains questions and choices. Each question has 4 choices which are radio buttons.</p>
  
  <p>I'm trying to display one question at a time on the same page along with the choices of the question. I've 2 buttons "previous" and "forward" which load the question on the same page.</p>
  
  <p><a href="https://i.stack.imgur.com/0wNqT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0wNqT.png" alt="enter image description here"></a></p>
  
  <p>When I click the next button the next question in the array along with the choices are displayed.When I click previous button the previous question is being displayed but not "with the checked radio button".
  Now my requirement is that the radio button checked in the previous question has to remain checked even after going to next question and when I click previous it has to show me which radio button have I checked.</p>
  
  <p>I'm trying to use [checked] option available with the radio button.But I'm not able to get it.Here is my code:</p>
  
  <pre><code>        &lt;div *ngIf="questions[indexVal]"&gt;
          {{indexVal+1}} {{questions[indexVal].Text}}
          &lt;div *ngFor="let choiceObj of questions[indexVal].choices"&gt;
              &lt;input name='question' type='radio' [value]='choiceObj' [(ngModel)]='selectedchoice'  (ngModelChange) = "storeChoice(choiceObj.choiceId,questions[indexVal])" 
  [checked]="check(questions[indexVal])"/&gt;
  
              &lt;label [for]='choiceObj'&gt; {{choiceObj.choiceText}} &lt;/label&gt;
  
              &lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;button ion-button value="previous" (click)="PrevQues()" [disabled] = 
   "disableprev"&gt; PREVIOUS &lt;/button&gt;
      &lt;button ion-button value="next" (click)="NextQues()"&gt; NEXT &lt;/button&gt;
  </code></pre>
  
  <p>Initially the indexVal=0 which means it is pointing to the first question.On clicking the next button it becomes indexVal+=1 and for previous it becomes indexVal-=1;</p>
  
  <p>here is my typescript code. I'm trying to maintain an array called "answers" which stores the selected choice.</p>
  
  <pre><code>    storeChoice(choiceId, questions[indexVal])
  {
        questions[indexVal].answers[0] = choiceId;
  
  }
  
  check(questions[indexVal])
  {
    return questions[indexVal].answers[0];
  }
  </code></pre>