我有以下指令:
angular.module("app").directive("validator", validator);
function validator() {
var validator = {
link: link,
replace: false,
require: "^validation",
restrict: "A"
};
return validator;
function link(scope, element, attributes, controller) {
}
}
我正在应用如下:
<span validator></span>
如何将可选参数传递给指令?类似的东西:
<span validator="arg value"></span>
还是更好?
<span validator validator-arg="arg value"></span>
然后我需要在链接函数内检查参数是否为null。