I have a set of question that come from a JSON file.
In my view I loop through these questions and output the type of input:
<div ng-repeat="question in questions" id="{{question.id}}">
<div ng-if="question.answerStyle == 'select'">
<select ng-model="question.answer">
<option value="" disabled selected hidden>Choose answer...</option>
<option ng-repeat="option in question.answers" ng-value="{{option}}">{{option.name}}</option>
</select>
</div>
</div>
In the controller I am watching the $scope.questions for any changes and then logging out the scope.
The answer is set as:
[object Object]
I need to pass the answer as an object as need the value and question text.
Example question data from Array:
[
{
"id":"questionId",
"answerType":"single",
"answerStyle":"select",
"title":"Question Title",
"answers":[
{
"value":0,"name":"3 years"
}
}
]
questionsarray