title: AngularJS pass Javascript object to controller
body: <p>I'm trying to pass a Javascript object into my AngularJS controller and having no luck.</p>
  
  <p>I've tried passing it into an <code>init</code> function:</p>
  
  <pre><code>&lt;div ng-controller="GalleryController" ng-init="init(JSOBJ)"&gt;
  </code></pre>
  
  <p>And on my controller side:</p>
  
  <pre><code>$scope.init = function(_JSOBJ)
  {
      $scope.externalObj = _JSOBJ;
      console.log("My Object.attribute : " + _JSOBJ.attribute );
  };
  </code></pre>
  
  <p>Though the above doesn't seem to work.</p>
  
  <p>Alternatively, I've tried pulling the attribute from the AngularJS controller that I am interested in for use in an inline <code>&lt;script&gt;</code> tag:</p>
  
  <pre><code>var JSOBJ.parameter = $('[ng-controller="GalleryController"]').scope().attribute ;
  console.log("My Object.parameter: " + JSOBJ.attribute );
  </code></pre>
  
  <p>Can anyone tell me: what is the best practice regarding this?</p>
  
  <p>I don't have the option to rewrite the plain Javascript object as it is part of a 3rd party library.</p>
  
  <p>Let me know if I need to provide further clarification and thanks in advance for any guidance!</p>
  
  <p>-- JohnDoe</p>