Angularjs 使用&;时如何将参数传递到隔离作用域;在自定义指令中?

Angularjs 使用&;时如何将参数传递到隔离作用域;在自定义指令中?,angularjs,angularjs-directive,angularjs-scope,Angularjs,Angularjs Directive,Angularjs Scope,我的控制器作用域中有一个函数 $scope.read = function(a, b, c){}; 我已将其绑定到我的自定义指令 <dir read="read(a, b, c)"></dir> angular.module('app').directive('dir', function() { restrict: 'E', scope: { read: '&' }, link: function() { read(a, b,

我的控制器作用域中有一个函数

$scope.read = function(a, b, c){};
我已将其绑定到我的自定义指令

<dir read="read(a, b, c)"></dir>
angular.module('app').directive('dir', function() {
  restrict: 'E',
  scope: {
    read: '&'
  },
  link: function() {
    read(a, b, c); 
  }
});
当我调试它时,这三个参数都是未定义的。
如何使其工作?

从指令调用函数的方法是:

link: function(scope, elem, attrs) {
    scope.read({a: your_a_argument, b: your_b_argument, c: your_c_argument});
}

如果要使用
=
将函数作为引用传递,并且仅将函数名作为valueOnly函数通过指令中的作用域声明绑定,请在链接函数中调用读取(1,2,3),因为a、b、c在指令作用域中不可用,您可能需要使用Nikos Paraskevopoulos解决的方法显式绑定每个参数。