title: angularjs directive call function specified in attribute and pass an argument to it
body: <p>I want to create a directive that links to an attribute. The attribute specifies the function that should be called on the scope. But I also want to pass an argument to the function that is determined inside the link function.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div my-method='theMethodToBeCalled'&gt;&lt;/div&gt;
  </code></pre>
  
  <p>In the link function I bind to a jQuery event, which passes an argument I need to pass to the function:</p>
  
  <pre class="lang-js prettyprint-override"><code>app.directive("myMethod",function($parse) {
    restrict:'A',
    link:function(scope,element,attrs) {
       var expressionHandler = $parse(attrs.myMethod);
       $(element).on('theEvent',function( e, rowid ) {
          id = // some function called to determine id based on rowid
          scope.$apply(function() {expressionHandler(id);});
       }
    }
  }
  
  app.controller("myController",function($scope) {
     $scope.theMethodToBeCalled = function(id) { alert(id); };
  }
  </code></pre>
  
  <p>Without passing the id I can get it working, but as soon as I try to pass an argument, the function is not called anymore</p>