2014-02-23 25 views

回答

3

是的,這是可能的:

.directive("...", function() { 
    return { 
     ... 
     require: ["ngModel", "foo", "bar"], 
     link: function(scope,elem,attrs.ctrl) { 
      var 
       ngModelCtrl = ctrl[0], 
       fooCtrl  = ctrl[1], 
       barCtrl  = ctrl[2]; 
      ... 
     } 
    }; 
}); 
2

是,其能夠傳遞數組或一個字符串。來源:

Require another directive and inject its controller as the fourth argument to the linking function. The要求takes a string name (or array of strings) of the directive(s) to pass in.