How to create dynamic radio buttons with multiple options
12,072
Add a "name" parameter:
<input name="{{question.description}}" type="radio" ng-model="question.answer" value="option.value">
Also, you need to change "value" to {{option.value}}
<input name="{{question.description}}" type="radio" ng-model="question.answer" value="{{option.value}}">
Author by
Mar
Updated on July 24, 2022Comments
-
Mar over 1 year
I am trying to create a dynamic form with multiple radio button options and get selected values..
<form name="myForm" ng-submit="sendAnswers(question)"> <ul> <li ng-repeat="question in questionForm.questions"> <p>{{question.description}}</p> <ul> <li ng-repeat="option in question.options"> <input type="radio" ng-model="question.answer" value="option.value"> {{option.value}} </li> </ul> </li> </ul> <p><input type="submit" value="sendAnswers"></p> </form>
Problem is as I click on button, both options get selected..what am I doing wrong here?
Live example: http://plnkr.co/edit/aStk4SCHzAW0AKQuH7JE?p=preview
Thanks in advance!