Reputation: 93
I am having problems sending compact data from controller to vue component as a props.
Code for Blade file:
<div id="hotjob">
<hotjob-component :projects="'{{ json_encode($Projects) }}'"></hotjob-component>
</div>
I also tried with {!! json_encode($Projects) !!
but it's still not working.
Code for Vue File:
props: ['projects'],
created()
{
console.log('From On created');
console.log(this.projects);
},
mounted()
{
console.log(this.projects);
console.log('Hot Job Mounted yeah');
}
This is the error I get:
invalid expression: Unexpected identifier in
Upvotes: 2
Views: 7082
Reputation: 175
Try with removing single quotes
<div id="hotjob">
<hotjob-component :projects="{{ json_encode($Projects) }}"></hotjob-component>
</div>
Like this.
Upvotes: 2
Reputation: 104
just pass the variable to the props directly :
<hotjob-component :projects='{{ $Projects }}'></hotjob-component>
this should do it
Upvotes: 0