title: Dynamic templateUrl - AngularJS
body: <p>So as of Angular 1.1.4, you can have a dynamic template url. From <a href="http://code.angularjs.org/1.1.4/docs/partials/guide/directive.html" rel="noreferrer">here</a>,</p>
  <blockquote>
  <p>templateUrl - Same as template but the template is loaded from the specified  URL. Because the template loading is asynchronous the compilation/linking is suspended until the template is loaded.</p>
  <p>You can specify templateUrl as a string representing the URL or as a  function which takes two arguments tElement and tAttrs (described  in the compile function api below) and returns a string value representing  the url.</p>
  </blockquote>
  <p>How can I utilize this to generate a dynamic template based on, say, an attribute on my directive? Obviously this doesn't work, since tAttrs.templateType is simply the string &quot;templateType&quot;</p>
  <pre><code>templateUrl: function (tElement, tAttrs) {
    if (tAttrs.templateType == 'search') {
      return '/b/js/vendor/angular-ui/template/typeahead/typeahead.html'
    } else {
      return '/b/js/vendor/angular-ui/template/typeahead/typeahead2.html'
    }
  }
  </code></pre>
  <p>Given that I don't have access to the scope, how do I manage this?</p>