title: angularJS share methods between directives
body: <p>how do I share a method between two directives? When I try it now the console says scope.triggerInput(); is undefined; If I replace the scope.triggerinput with just a string it works. So I guess I do it somewhere wrong in the attribute.</p>
  
  <pre><code>app.directive('myImage', function () {
      return{
           restrict: 'A',
           template: ' &lt;img ng-src="images/needed/noPhoto.png"class="hover"&gt;',
           link: function (scope, element, attr) {
                element.bind('click', function () {
                     scope.triggerInput();
                });
            }
       };
  });   
  
  app.directive('myFileInput', function (httpPostFactory) {
          return{
              restrict: 'A',
              scope: {
                  triggerInput: '='
              },
              link: function (scope, element, attr) {
                  scope.triggerInput = function () {
                      console.log('triggerInput');
                      element[0].click();
                  };
              }
          };
      });
  </code></pre>
  
  <p>html</p>
  
  <pre><code>&lt;div data-my-image&gt;&lt;/div&gt;
  &lt;input data-my-file-input type="file" name="file" triggerInput='triggerInput()'&gt;
  </code></pre>