1

I'm trying to populate a table dynamically with cells component.

input structure looks like:

tableData: {
    headers: ['1', '3', '2', '4'],
    rows: [
      [{h: '1', t: 'Sample', v: {name: 'logan'}},
      {h: '2', t: 'Sample', v: {name: 'dgd'}},
      {h: '3', t: 'Sample', v: {name: 'logasdn'}},
      {h: '4', t: 'Sample', v: {name: 'loezgan'}}]
    ],
    showHeaders: ['1', '2', '3']
  }

the html sections looks like that:

<!--table data-->
    <tr v-for='(row,rowIndex) in tableData.rows'>
      <td><input type='checkbox'></td>

      <td v-for="(element,colIndex) in row">

        <component is='Sample' v-bind='element.v' ></component>
      </td >

    </tr>

When I pass 'Sample' (the component name) as parameter it works, but its not when I replace 'Sample' by 'element.t' or {{element.t}} which I don't understand.

Does anyone knows why its not working and how to do that?

2
  • Remove the quotes around Sample in rows. Commented Aug 24, 2017 at 16:19
  • could you elaborate a bit more? are you talking about the tr tag? Commented Aug 24, 2017 at 16:26

1 Answer 1

1

You need to bind to is via v-bind:is or the shorthand :is:

<component :is='element.t' v-bind='element.v'></component>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.