I have a partial view with a script I want to include in all my views, I dont't wanna @include this partial in all my layouts and blade views but instead add it to all rendered views, my partial looks like this:
<script type="text/javascript">window.$app = {!! json_encode(app(App\Helpers\Javascript::class)->app) !!};</script>
How can I do this?
You could:
<html>
and <body>
tags)put
some data from PHP in a custom JS namespace (eg window.yourNameSpace
). And then use it from a View Composer or the specific controller's methods concerned by your views.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.