I have been able to pass the data from blade
to vue component
.
But, i wanted to emit the value from the vue component
to blade object when value is changed on vue
.
Vue Component
<template>
<div>
<b-form-select v-model="jobId" :options="employees" class="form-control mb-3">
<!-- This slot appears above the options from 'options' prop -->
<template slot="first">
<option :value="null" disabled>Job Type</option>
</template>
</b-form-select>
<template v-if="jobId==1">
<b-button>Assign Course</b-button>
<b-table :items="items" class="mt-3" outlined>
<div slot="table-busy" class="text-center text-danger my-2">
<strong>Loading...</strong>
</div>
</b-table>
</template>
</div>
</template>
Script In Vue Component
<script>
export default {
props: {
job_id: {
type: String
},
employee: {
type: String,
required: true
}
},
data() {
return {
jobId: this.job_id,
employees: JSON.parse(this.employee),
isBusy: false,
items: [
{ first_name: "Dickerson", last_name: "MacDonald", age: 40 },
{ first_name: "Larsen", last_name: "Shaw", age: 21 },
{ first_name: "Geneva", last_name: "Wilson", age: 89 },
{ first_name: "Jami", last_name: "Carney", age: 38 }
]
};
},
computed: {},
mounted() {
console.log("Component mounted.");
},
method: {
toggleBusy() {
this.isBusy = !this.isBusy;
},
addNewContact() {}
}
};
</script>
Laravel Blade
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Employee Type</h3>
</div>
<div class="box-body">
{{$employee->job_id}}
<div id="app">
//Vue Component
<course job_id="{{$employee->job_id}}" employee="{{$jobs}}"></course>
</div>
</div>
<!-- /.box-body -->
</div>
Is it possible to emit when jobId
is changed in vue component
to bind the value to $employee->job_id
in blade?
Alternatively, is it possible for two way binding between blade
and vue component?