Reputation: 24679
Is it possible to use the require
attribute in order to require several directives instead of just one?
If so can I pass an array of directives to this require
attribute?
Upvotes: 1
Views: 42
Reputation: 5460
Yes, its possible to pass an array or a string. From the source:
Require another directive and inject its controller as the fourth argument to the linking function. The
requiretakes a string name (or array of strings) of the directive(s) to pass in.
Upvotes: 2
Reputation: 40298
Yes, it is possible:
.directive("...", function() {
return {
...
require: ["ngModel", "foo", "bar"],
link: function(scope,elem,attrs.ctrl) {
var
ngModelCtrl = ctrl[0],
fooCtrl = ctrl[1],
barCtrl = ctrl[2];
...
}
};
});
Upvotes: 3