I am fetching data from API. My data looks like -
[
{
id:1,
name:nameOfTheGroup1,
participants:[
{
id:1,
name:participant1
},
{
id:2,
name:participant2
}
]
},
{
id:2,
name:nameOfTheGroup2,
participants:[
{
id:3,
name:participant1
},
{
id:4,
name:participant2
}
]
}
]
As you can see its an array of objects. and in each object has nested array of objects. Basically i am trying to fetch all the groups for current user with its participants.
Now i am showing those in the browser using v-for like this -
<h3>Please assign an admin to given groups</h3>
<div v-for="group in groups">
{{ group.name }}
<div v-for="participant in group.participants">
<input type="radio" value="" v-model=""/>
<label>{{ participant.name }} </label>
</div>
</div>
Now, my question is how can i bind this data using v-model to get object/array with
group id and assigned user (radio checked ).
This is my best how i could explain))
Thanks.
You are binding v-model directly to a v-for iteration alias. This will not be able to modify the v-for source array because writing to the alias is like modifying a function local variable. Consider using an array of objects and use v-model on an object property instead