title: How to access global js variable in AngularJS directive
body: <p>First of all, I checked and I didn't find any article covering my question.</p>
  
  <p>How to access a pre-defined js global variable in angularJS built-in directive?</p>
  
  <p>For example, I define this variable in <code>&lt;script&gt;var variable1 = true; &lt;/script&gt;</code> </p>
  
  <p>Then I write a AngularJS directive:</p>
  
  <p><code>&lt;div ng-if="variable1"&gt;Show some hidden stuff!&lt;/div&gt;</code></p>
  
  <p>This does not really work.</p>
  
  <p>Then I'm informed that I should use <code>ng-init</code></p>
  
  <p>So I wrote code somewhere else like:</p>
  
  <p><code>&lt;div ng-init = "angularVariable1 = variable1"&gt;&lt;/div&gt;</code></p>
  
  <p>And this apparently does not work as well...this is like a vicious cycle. You need to access pre-defined js global variables, then you need to use ng-init; in order to use ng-init, you need to access global variables.</p>
  
  <p>Any particular way to do this?</p>