是否可以使用require
属性来要求多个指令而不是一个?
如果是这样,我可以将一组指令传递给这个require
属性吗?
答案 0 :(得分:3)
是的,有可能:
.directive("...", function() {
return {
...
require: ["ngModel", "foo", "bar"],
link: function(scope,elem,attrs.ctrl) {
var
ngModelCtrl = ctrl[0],
fooCtrl = ctrl[1],
barCtrl = ctrl[2];
...
}
};
});
答案 1 :(得分:2)
是的,可以传递数组或字符串。来自消息来源:
Require another directive and inject its controller as the fourth argument to the linking function. The
{要求{1}}