title: Dynamic controller for directives with ECMA6
body: <p>I'm trying to set a controller dynamically to my directive using the <code>name</code> property. So far this is my code.</p>
  
  <p>html</p>
  
  <pre><code>&lt;view-edit controller-name="vm.controller" view="home/views/med.search.results.detail.resources.audios.html" edit="home/views/med.media.resources.edit.html"&gt;&lt;/view-edit&gt;
  </code></pre>
  
  <p>js</p>
  
  <pre><code>export default class SearchResultsCtrl extends Pageable {
  
    /*@ngInject*/
    constructor($injector, $state, api) {
  
      super(
        {
          injector: $injector,
          endpoint: 'mediaMaterialsList',
          selectable:{
            itemKey: 'cid',
            enabled:true,
            params: $state.params
          },
          executeGet: false
        }
      );
  
      this.controller = SearchResultsResourcesAudiosCtrl;
    }
  }
  </code></pre>
  
  <p>Directive</p>
  
  <pre><code>export default class ViewEditDirective {
  
    constructor() {
      this.restrict = 'E';
      this.replace = true;
      this.templateUrl = 'home/views/med.view.edit.html';
      this.scope = {};
      this.controller = "@";
      this.name = "controllerName";
      this.bindToController = {
        'view': '@?',
        'edit': '@?'
      };
  
      this.open = false;
      this.controllerAs = 'ctrl';
    }
  }
  </code></pre>
  
  <p>I get <code>undefined</code> for <code>vm.controller</code>. I guess that it's rendering before the controller can assign the controller to the variable (I debbuged it, and it's setting the controller in the variable).</p>
  
  <p>I'm following this answer to achieve this, but no luck so far.
  <a href="https://stackoverflow.com/questions/19444414/how-to-set-the-dynamic-controller-for-directives">How to set the dynamic controller for directives?</a></p>
  
  <p>Thanks.</p>