title: Angular js load template into templateCache using template url
body: <p>I'm trying to load a template into <code>$templateCache</code> in the module's run block as follows.</p>
  
  <pre><code>angular.module('myapp').run(function($http, $templateCache, $timeout) {
      var templateLocation = 'location/to/template.html';
      $http.get(templateLocation).them(function(response) {
          $templateCache.put(templateLocation, response.data);
      )};
  }
  </code></pre>
  
  <p>This loads the template into templateCache. However, when I try to use it in a directive. It doesn't load because the directive loads before the <code>$http</code> promise gets resolved.</p>
  
  <p>Here is the code for directive</p>
  
  <pre><code>angular.module('myApp').directive('myDirective, directiveFn);
  directiveFn.$inject = ["$templateCache"]
  
  function directiveFn($templateCache) {
      var templateLocation = 'location/to/template.html';
      return {
          restrict: 'EA'
          scope: {
              thing1: "="
          }
          template: $templateCache.get(templateLocation)
      }
  }
  </code></pre>
  
  <p>Is there a better way/place to do this? </p>