Please look into my controller
class myController extends Controller
{
$markets = Market::all();
\JavaScript::put([
'markets' => $markets,
]);
return view('test.index');
}
Using this method, I can get all markets in my angularjs file in markets
variable.
I saw something like below
class myController extends Controller
{
$markets = Market::all();
return view('test.index', compact($markets));
}
which one would I prefer? what is the advantages of both? what is the difference of both?