Beto A. Lien
Beto A. Lien

Reputation: 43

Laravel + Vue load component inside @foreach on blade

Good night

I have the next @foreach in my home.blade.php

 @foreach($User as $User1)
        <tr>
    <td>{{$User1->name}}</td>
        <td>{{$User1->email}}</td>
        <td>{{$User1->pais}}</td>
            <td>{{$User1->status}}</td>
    <td>
<div id='app'>
    <calculadora-component></calculadora-component>
</div>
    </td>
        </tr>
@endforeach

But the calculadora-component not works with the @foreach, how can I do it?

And this is my vue component for the moment,

   <template>
    <div id="app">
        <select v-on:change="onSelectOption($event)" class="form-control" name="status">
            <option value="" disabled selected hidden>Seleccionar una Opción</option>
            <option value="Activo" selected>Activo</option>
            <option value="Inactivo">Inactivo</option>
        </select>
    </div>
</template>

Upvotes: 0

Views: 1490

Answers (1)

J&#225;n Kl&#225;tik
J&#225;n Kl&#225;tik

Reputation: 40

You have to wrap that foreach loop into a div with the app id like this:

<div id='app'>
@foreach($User as $User1)
        <tr>
    <td>{{$User1->name}}</td>
        <td>{{$User1->email}}</td>
        <td>{{$User1->pais}}</td>
            <td>{{$User1->status}}</td>
    <td>
<div>
    <calculadora-component></calculadora-component>
</div>
    </td>
        </tr>
@endforeach
</div>

Upvotes: 1

Related Questions