我想将参数传递给'(属性)受限制指令的范围:
我有以下' E'限制指令
.directive("twValidation", function () {
return{
restrict: "E",
replace: true,
scope: {
field: '='
},
templateUrl: "partials/components/directives/common/tw-validation.tpl.html"
}
})
我这样用:
<tw-validation field="myField"></tw-validation>
但最终我想要这个:
<div tw-validation="myField">...</div>
如何在属性限制指令内传递参数?
答案 0 :(得分:1)
.directive("twValidation", function () {
return{
restrict: "A",
replace: true,
scope: {
twValidation: '='
},
templateUrl: "partials/components/directives/common/tw-validation.tpl.html"
}
答案 1 :(得分:0)
请尝试以下方法:
.directive("twValidation", function () {
return{
restrict: "E",
replace: true,
scope: {
field: '=field'
},
templateUrl: "partials/components/directives/common/tw-validation.tpl.html"
}
<tw-validation field="myField"></tw-validation>