Lord Vermillion
Lord Vermillion

Reputation: 5424

Vue bind element data to html property

i want to bind selected rows to an array, i'm trying to bind data from a v-for to the value of my input. I tried v-bind:value="row.id", i tried value={{row.id}} but nothing seems to be working.

<tbody>
  <tr v-for="row in get_rows()">
    <td>
      <input type="checkbox" v-bind:value="row.id" v-model="selectedRows">
    </td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</tbody>

What am i doing wrong?

Upvotes: 0

Views: 80

Answers (1)

dfsq
dfsq

Reputation: 193311

In order for your code to work you need to make sure you initialize selectedRows as an array. Add this to your component:

data() {
  return {
    selectedRows: []
  }
},

Upvotes: 1

Related Questions