title: Pass angular directive scope to directive controller
body: <p>I'm currently learning to use directives in AngularJs, and even though I know Angular 2.0 is still just in alpha, I've started reading into "preparing for angular 2.0" articles around the web.  </p>
  
  <p>There's quite a bit of them that mention stepping away from the link function and using the controller and bindToController just to make directives act a bit more like an Angular 2.0 "component".</p>
  
  <p>The problem I'm having is that I don't really know how to pass my directive scope to the controller I'm using for that directive...<br>
  For instance, when given the following directive:  </p>
  
  <pre class="lang-js prettyprint-override"><code>(function() {
    'use strict';
  
    angular.module('app').directive('gidsImagePreview', imagePreview);
  
    /* @ngInject */
    function imagePreview() {
      var directive = {
          restrict: 'EA',
        templateUrl: 'scripts/directives/gidsImagePreview.directive.html',
        scope : {
              images : '='
          },
        controller: ImagePreviewController,
        controllerAs: 'vm',
              bindToController: true
      };
  
      return directive;
    }
  
      /* @ngInject */
    function ImagePreviewController(){
          var self = this;
          self.featured = self.images[0];
          self.preview = preview;
  
          function preview(img){
              self.featured = img;
          }
    }
  })();
  </code></pre>
  
  
  
  <p>And the following html to "call" the directive (vm.project.images is an array of image objects with a filename property):</p>
  
  <pre><code>&lt;gids-image-preview images="vm.project.images"&gt;&lt;/gids-image-preview&gt;
  </code></pre>
  
  <p>Then, how is it that my "self.images" in the ImagePreviewController is always undefined?  </p>
  
  <p>Reading <a href="https://www.airpair.com/angularjs/posts/component-based-angularjs-directives" rel="nofollow">this article</a>, he/she seems to be doing exactly what I'm doing (just not with an array object)...</p>