Hey all,
I’ve got an ionic slidebox which contains an ng-repeat:
<ion-slide ng-repeat="question in selectedQuestions">
Inside this, I have a 4 ion-radio’s:
<ion-radio ng-model="qData.qSelected" checked class="item-text-wrap" ng-click="userAnswer('A')" ng-value="question.userAnswer">
{{question.userAnswer}}
<h2 ng-bind-html="question.answer1|toString|answerToImage">{{question.answer1|toString|answerToImage}}</h2>
</ion-radio>
<ion-radio ng-model="qData.qSelected" class="item-text-wrap" ng-click="userAnswer('B')" ng-value="question.userAnswer">
<h2 ng-bind-html="question.answer2|toString|answerToImage">{{question.answer2|toString|answerToImage}}</h2>
</ion-radio>
<ion-radio ng-model="qData.qSelected" class="item-text-wrap" ng-click="userAnswer('C')" ng-value="question.userAnswer">
<h2 ng-bind-html="question.answer3|toString|answerToImage">{{question.answer3|toString|answerToImage}}</h2>
</ion-radio>
<ion-radio ng-model="qData.qSelected" class="item-text-wrap" ng-click="userAnswer('D')" ng-value="question.userAnswer">
<h2 ng-bind-html="question.answer4|toString|answerToImage">{{question.answer4|toString|answerToImage}}</h2>
</ion-radio>
Now, for the functionality for my app, there is a way for a user to save their progress. In this process, I save a custom selectedQuestions
array which contains the field userAnswer for each question the user has answered. In the userAnswered
field, values inside will look like either “A”, “B”, “C” or “D”.
qData.qSelected
also contains the users answer for a specific slide. However, I’ve tried almost everything to preset these ion-radio’s to the users old selected answers without any luck.
So my question is, are there any ways to set an ion-radio to be pre-selected via HTML? That way I could use ng-if’s or something similar to do this.
Alternatively are there any classes or other ways anyone can think of to preset ion-radio’s on load based off an array?
Thanks!