title: Passing parameters to scope function from directive inside ng-repeat
body: <p>I am trying to call a function from a directive and pass a parameter.  The callback function is being passed in to the isolate scope.  I have two problems.  First, this doesn't work at all when nested inside an ng-repeat and second, even when not in ng-repeat it I don't know how to pass a parameter to the callback function.  Here is a plunker showing the problem: <a href="http://plnkr.co/edit/3FN0o3UE99wsmUpxMe4x?p=preview" rel="nofollow">http://plnkr.co/edit/3FN0o3UE99wsmUpxMe4x?p=preview</a></p>
  
  <p>Notice that when you click on "This works", it at least executes the function from the parent scope, but when clicking on the others, it does nothing (because they're inside an ng-repeat).  That's the first problem.</p>
  
  <p>The second problem is that when you click on "This works", even though it successfully calls the function, I can't figure out how to pass along the user from the directive scope (notice that it alerts undefined).</p>
  
  <p>Here is a sample directive (much simplified from my real-world application):</p>
  
  <pre><code>var app = angular.module('plunker', []);
  app.controller("AppCtrl", function($scope) {
    $scope.click = function(user) {
      alert(user)
    }
    $scope.users = [{
      name: 'John',
      id: 1
    }, {
      name: 'anonymous'
    }];
  });
  app.directive("myDir", function($compile) {
    return {
      scope: {
        user: '=',
        click: '&amp;'
      },
      compile: function(el) {
        el.removeAttr('my-dir');
        el.attr('ng-click', 'click(user)')
        var fn = $compile(el);
        return function(scope, el){
          fn(scope);
        };
      }
    };
  });
  </code></pre>
  
  <p>Here is the html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html ng-app="plunker"&gt;
  
    &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;AngularJS Plunker&lt;/title&gt;
      &lt;script&gt;document.write('&lt;base href="' + document.location + '" /&gt;');&lt;/script&gt;
      &lt;link rel="stylesheet" href="style.css" /&gt;
      &lt;script data-require="angular.js@1.2.x" src="http://code.angularjs.org/1.2.12/angular.js" data-semver="1.2.12"&gt;&lt;/script&gt;
      &lt;script src="app.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;div ng-controller="AppCtrl"&gt;
          &lt;a my-dir user="{name: 'Works', id: 0}" click="click()"&gt;This works&lt;/a&gt;
          &lt;a my-dir user="user" click="click()" ng-repeat="user in users"&gt;&lt;br&gt;{{user.name}}&lt;/a&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks!</p>