Answer the question
In order to leave comments, you need to log in
How to move dynamic js out of a view into a separate file?
It is not recommended to use inline js in templates. But what about the js in which the data of the model objects is substituted, let's say, going through the collection with foreach to display the data on chart.js charts.
For example, like this:
datasets: [
@foreach ($demandArray as $keyword => $values)
{
label: '{{$keyword}}',
data: [@foreach($values as $key => $value) {{$value}} @endforeach],
fill: false,
borderColor: colors.pop()
},
@endforeach
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question