I'm trying to get this package to work: https://github.com/laracasts/PHP-Vars-To-Js-Transformer
I did everything according to the description, but I get no output of the variables.
Laravel Version: laravel/framework (v5.2.24)
My config/app
Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class,
'JavaScript' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class,
My config/javascript
'bind_js_vars_to_this_view' => 'footer',
'js_namespace' => 'qwerTEST'
in my controller
use JavaScript;
JavaScript::put(['fett' => 'testtesttest']);
in my main view
@include('layouts.footer');
my footer.blade.php
`<div>some text</div>`
and in my view
@extends('layouts.intern')
@section('content')
<script>
console.log('test');
console.log(qwerTEST.fett);
</script>
@endsection
the javascript of chrome gives out
test
Uncaught ReferenceError: qwerTEST is not defined
And there is nothing with qwerTEST javascript namespace in the sourcecode. But I get no error at all.
Am I missing something?
I found it: in my config/javascript I have to write the full path to the view:
'bind_js_vars_to_this_view' => 'folder.footer'
Could be better described in the Package..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With