title: AngularJS Directive: Attaching a function from the controller to ng-click
body: <p>I've run into some trouble trying to write a directive to make a generic tool-tip which accepts as arguments a user id, and different actions associated with that id. Each action has it's own method in the controller and it's own icon.</p>
  
  <p>This is the HTML</p>
  
  <pre><code>&lt;tr ng-repeat="user in users"
      row-actions id="user.id" actions="[{'action': editUser ,'icon': 'edit'}, {'action': removeUser, 'icon': 'trash'}]"&gt;
      &lt;td&gt;{{user.name}}&lt;/td&gt;
      &lt;td&gt;{{user.unit.name}}&lt;/td&gt;
      &lt;td&gt;{{user.roleName}}&lt;/td&gt;
      &lt;td&gt;{{user.active ? 'ACTIVE' : 'NON_ACTIVE' | translate}}&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>This is the directive</p>
  
  <pre><code>myApp.directive('rowActions',['$compile', function($compile){
        return {
          restrict: 'A',
          scope: {
            id: '=',
            actions: '='
          },
          link: function (scope, element, attr) {
            var div = angular.element('&lt;div class="row-actions"&gt;&lt;/div&gt;');
            for (var i=0; i &lt; scope.actions.length; i++) {
              div.append('&lt;span class="row-action icon icon-' + action.icon + ' icon-white" ng-click="' + action.action + '(' + scope.id + ')' + '"&gt;&lt;/span&gt;');
            }
  
            element.append(div);
  
            $compile(element);
          }
        };
      }]);
  </code></pre>
  
  <p>Basically, the methods are editUser and removeUser, I'd like to be able to call them as editUser(user.id), etc, but I can't get it to compile.
  I tried sending them as strings ('editUser'), and in the example they are sent as functions. Neither works.</p>
  
  <p>Please take a look,
  Thank you</p>