title: ng-template to Variable from src
body: <p>I want to load the contents of my template into a variable. At the moment my Code looks like this.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;script type="text/ng-template" id="a.html" src="templates/a.html"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>vm.template = $templateCache.get('a.html');
  console.log("Template: " + vm.template);
  </code></pre>
  
  <p>This should Load the contents of 'templates/a.html' into vm.template. Sadly this does not work. The variable vm.template doesn't contain the template.</p>
  
  <p><a href="https://i.stack.imgur.com/iXg8f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iXg8f.png" alt="The variable does not contain the template"></a></p>
  
  <p>What I found out while testing is that if i write the contents of the template directly into the script tags like this</p>
  
  <pre><code>&lt;script type="text/ng-template" id="a.html"&gt;Hello!&lt;/script&gt;
  </code></pre>
  
  <p>It actually works.</p>
  
  <p><a href="https://i.stack.imgur.com/bplbJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bplbJ.png" alt="The variable contains the template"></a></p>