title: Angular conditional template in directive; decision based on isolate scope variable from promise
body: <p>basically I try to do conditional formatting of addresses.</p>
  
  <p>I did a plnkr for a visualization of the simplified problem:
  <a href="http://plnkr.co/edit/A5eV96H9eKIua9mJyKSL?p=preview" rel="nofollow">http://plnkr.co/edit/A5eV96H9eKIua9mJyKSL?p=preview</a> </p>
  
  <p>A directive is responsible to display the right template:</p>
  
  <pre><code>app.directive('tqFormatAddress', function(){
    return {
      restrict: 'E',
      scope: {
        address:'='
      },
      link: function (scope, element, attrs) {
        switch(scope.address.country) {
        case "de":
           scope.template = 'adress-de.html';
           break;
        case "uk":
           scope.template = 'adress-uk.html';
           break;
        }
      },
      template: '&lt;ng-include src="template"&gt;&lt;/ng-include&gt;',
    };
  });
  </code></pre>
  
  <p>Is this the right way of doing things like this?</p>
  
  <p>The next step was to integrate the code into my application. I get the data using a <code>$resource</code>:</p>
  
  <pre><code>$scope.ansprechpartner = this.Ansprechpartner.get({id: $routeParams.id});
  </code></pre>
  
  <p>In the view:</p>
  
  <pre><code>&lt;tq-format-address address="ansprechpartner.Dienstadresse"&gt;&lt;/tq-format-address&gt;
  </code></pre>
  
  <p>Now I get an error in the directive because the resource isn't resolved yet.</p>
  
  <p>One way would be to supply the whole <code>ansprechpartner</code> to the directive:</p>
  
  <pre><code>&lt;tq-format-address address="ansprechpartner.Dienstadresse" promise="ansprechpartner"&gt;&lt;/tq-format-address&gt;
  </code></pre>
  
  <p>And then do something like this(untested demonstration code):</p>
  
  <pre><code>    link: function (scope, element, attrs) {
        ansprechpartner.then(function () {
            switch(scope.address.country) {
            case "de":
               scope.template = 'adress-de.html';
               break;
            case "uk":
               scope.template = 'adress-uk.html';
               break;
            }
        });
      },
  </code></pre>
  
  <p>Is there be another way doing this without the promise?</p>