title: Conditional choice of directive
body: <p>I want to choose which directive to use based on a variable. Specifically, I have items of several different types in a list, so I would like to use the item type to choose the directive that can display it. </p>
  
  <p>ng-switch seems intended for this purpose. However, it adds all of the switch choices into the DOM, then hides all but one. That approach seems inefficient if there are many item types or a long list to display. Also, using a switch puts the logic in the HTML. Preferred would be a 'strategy pattern' that would just choose the right directive, perhaps like</p>
  
  <pre><code>&lt;display-{{item.type}} data="item.data" /&gt;
  </code></pre>
  
  <p>where the directives are 'displayType1', 'displayType2', and so on. However, this syntax seems not to work, perhaps because of the difference between the compile and linking phases. <a href="https://coderwall.com/p/mgtrkg" rel="noreferrer">Here</a> is an example that switches html templates inside a directive. But is there a way to switch directives, retaining their modularity?</p>