When creating a new poll, the question and all the potential answers need to be send to the controller once submitted. I know how to work with ng-model, but I have no clue how I can bind it to an array in that array.
For example, my array looks like this:
var question = {
"question":"",
"choices": [
{
"id":1,
"choice": "Yes"
},
{
"id"=2,
"choice": "No"
}
]
}
Form
<form novalidate name="questionForm" ng-submit="addVote(vote)">
<input placeholder="Type your question..." name="question" ng-model="vote.question" />
<input ng-model="" value="Choice 1" />
<input ng-model="" value="Choice 2" />
<button type='submit' class="circle-btn btn-send ion-ios-paperplane"></button>
</form>
The input[name=question] will obviously send whatever is in that input box to vote.question. But how do I add those potential answers to the choices array?
Note: it's possible to add more input fields
EDIT
So in short: I need to be able to bind {id:1, choice: value of input}