0👍
First create one input hidden field in your blade template
<input type value="{{data}}" class="chartdata" >
then you can call like this
datasets:$('.chartdata').val()
if you dont like to create input then you can use script in blade
<script>
var chartdata='{{data}}'
</script>
then in js file
datasets:chartdata
0👍
Get Data from the controller to blade.
Controller Code
$dashboard_data = [
'months' => $months,
];
return view('admin.layouts.dashboard', compact('dashboard_data'));
get data directly in the blade and call chart function if data are available.
@section('scripts')
<script>
<?PHP
if (isset($dashboard_data['months']) && !empty($dashboard_data['months'])) {
?>
var months = <?= $dashboard_data['months'] ?>;
<?PHP
}
</script>
@endsection
Source:stackexchange.com