title: AngularJS access directive controller variable in directive link function
body: <p>Although this question has been asked before, it is not working for me.  The controller variable "myVar" is set before the link function is called.  And according to docs and other posts myVar should be available in the link function, but it is not.  In fact the link scope contains a parent controller reference, but no reference to its own controller???  Any ideas?</p>
  
  <pre><code>angular.module('app.main')
      .directive('myWidget', MyWidget)
      .controller('MyWidgetCtrl', MyWidgetCtrl)
  
  function MyWidget() {
      return {
          restrict: 'E',
          templateUrl: 'my-widget-tmpl.html',
          controller: MyWidgetCtrl,
          link: function (scope, element, attrs) {
              var test = false;
              test = myVar;  // doesn't work
              test = scope.myVar;  // doesn't work
              test = scope.vm.myVar;  // doesn't work
          }
      };
  }
  
  MyWidgetCtrl.$inject = ['$scope'];
  function MyWidgetCtrl($scope) {
      var vm = this;
      vm.myVar= true;
  }
  </code></pre>