JSON
{
"Question": "A question",
"AnswerValue": "2",
"EnumValue": {
"Name": "name",
"SomeEnum": {"1": "option1", "2": "option2", "3": "option3"}
}
"Question": "A second question",
"AnswerValue": "3",
"EnumValue": {
"Name": "name",
"SomeEnum": {"1": "option1", "2": "option2", "3": "option3"}
}
}
In the JSON I have some questions with answers. The stucture of the JSON cannot be changed.
In my frontend there are checkboxes with the questions and answers (checked if AnswerValue == SomeEnum )
All enum values must be shown on the front end. The checkbox must be checked if AnswerValue == SomeEnum
The problem is if you use a repeat to loop trough the answers the enum list wil be dublicated if you have multiple answers (see below)
[ ] option1<br>
[x] option2<br>
[ ] option3<br>
[ ] option1<br>
[ ] option2<br>
[x] option3<br>
What I need is this:
[ ] option1<br>
[x] option2<br>
[X] option3<br>
HTML:
<div ng-repeat="(key, answer) in somevalue.EnumValue.SomeEnum">
<div ng-if="key==somevalue.AnswerValue">
<input type="checkbox" ng-checked="true"><br>
</div>
<div ng-if="key!=somevalue.AnswerValue">
<input type="checkbox"><br>
</div>
</div>
What I need is a generic solution because the questions have different sets of enums values the sub questions (within one question) have the same set of enum values
Aucun commentaire:
Enregistrer un commentaire