title: How to: pass data from controller to JavaScript in Laravel 4?
body: <p>I'm developing a mobile web app with Laravel 4 and jQuery Mobile and I have some problems to pass data from Controller to JavaScript file. I find a solution but I think there is a proper way to do that.</p>
  
  <p>Here is my code:</p>
  
  <p><strong>MapController.php</strong></p>
  
  <pre><code>class MapController extends BaseController 
  {
      public function showMap($id)
      {
          $club = Club::find($id);
          return View::make('pages.map', array('club' =&gt; $club));
      }
  }
  </code></pre>
  
  <p><strong>pages/map.php</strong></p>
  
  <pre><code>&lt;div id="picture" data-role="dialog"&gt;
    &lt;div data-role="header" data-theme="d"&gt;
      &lt;h1&gt;
        Upload picture
      &lt;/h1&gt;
    &lt;/div&gt;
    &lt;div data-role="content"&gt;
      code here...
    &lt;/div&gt;
  
    &lt;script type="text/javascript"&gt;
      var id_club = '&lt;?php echo $club-&gt;id ?&gt;';
    &lt;/script&gt;
    &lt;script src="public/js/map.js" type="text/javascript"&gt;
    &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Does anyone know if there is a better solution to pass data from controller to JavaScript?</p>