title: Using functions from directive controller within link function of same directive
body: <p>Perhaps I have a fundamental misunderstanding of how directive controllers work, from what I understand they are used as a sort of API to be exposed to other directives &amp; controllers. I am trying to get the controller and link function to communicate internally.</p>
  
  <p>For example I would like to be able to set a variable via the controller function and then use it in the link function:</p>
  
  <pre><code>var app = angular.module('test-app', []);
  
  app.directive('coolDirective', function () {
      return {
          controller: function () {
              this.sayHi = function($scope, $element, $attrs) {
                  $scope.myVar = "yo"
              }
          },
          link: function(scope, el, attrs) {
              console.log(scope.myVar);
          }   
      }
  });
  </code></pre>
  
  <p>How can I access myVar or sayHi within the link function? Or have I just missed the point completely?</p>