title: Access global variable from AngularJS
body: <p>I want to initialize a Angular model with a JSON object which is embedded in a HTML page. Example:</p>
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
        var tags = [{&quot;name&quot;: &quot;some json&quot;}];
      &lt;/script&gt;
      &lt;ul&gt;
        &lt;li ng-repeat=&quot;tag in tags&quot;&gt;{{tag.name}}&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The <code>tags</code> field cannot be resolved, because it is looked up in the <code>$scope</code>. I tried to access the <code>tags</code> field in my controller like this:</p>
  <pre><code>function TagList($scope, $rootScope) {
    $scope.tags = $rootScope.tags;
  }
  </code></pre>
  <p>But it doesn't work.</p>
  <p>It works only if I include the <code>TagList</code> directly into the HTML page and render the JSON directly into this function.</p>
  <p>How can I access the <code>tags</code> field in a separate js file in a Angular controller?</p>