1 year ago

Add id from v-for to dom elements

Posted 1 year ago by nanadjei2

I am making a for loop with vuejs and displaying a list of users in a table. I want to add the id of users to the action attribute of a form element or classes of the elements in the table items.

This is my html:

    <tr v-for="(user, key, index) in users">
         <td>@{{ key+1 }}</td>
         <td v-text=""></td>
         <td>@{{ }}</td>
         <td>@{{ user.status }}</td>
       <div class="btn-group pull-rights" role="group" aria-label="action-btns">
    <form id="statusform" :action="baseUrl+/" method="POST">
    <label class="ui-switch mt-1 mr-2">
      <input @click="onSwitchStatus(" type="checkbox" :checked="user.status == 'active'" :value="user.status">    

Am using laravel. I want the action attribute of the form to be for example… ‘localhost/project/user/edit/1/’ but it is not working. Can anyone help me;

Please sign in or create an account to participate in this conversation.