laravel-5 passing variable to JavaScript

前端 未结 6 1099
慢半拍i
慢半拍i 2020-11-30 00:26

is there any ways that JavaScript can get the variable from compact controller Laravel-5.

Example: I have the code below:

   $langs = Language::all()         


        
6条回答
  •  我在风中等你
    2020-11-30 01:15

    Is very easy, I use this code:

    Controller:

    $langs = Language::all()->toArray();
    return view('NAATIMockTest.Admin.Language.index', compact('langs'));
    

    View:

    
    

    hope it has been helpful, regards!

提交回复
热议问题