Reputation: 1422
app.directive('myCustomAttr',function() {
return {
restrict: 'A',
scope: {
valueOfAttr : "@myCustomAttr"
},
};
});
How would I pass the value of the attribute? Thus far, I've only found examples that use restrict : 'E'.
<input type="text" my-custom-attr="myValue" />
So, if I were going to bind "myValue" to the scope, how would I do that?
[EDIT]
Sorry, I had a typo. I was using the my-custom-attribute correctly, but it still doesn't seem to bind in the directive.
Upvotes: 0
Views: 118
Reputation: 590
I'm pretty sure you want =myCustomAttr
instead of @myCustomAttr
. There's mention of this under "Isolating the Scope of a Directive". There's also more information here.
Upvotes: 1
Reputation: 651
use the link function:
link: function (scope, element, attrs) {
var myAttr = attrs["myCustomAttr"];
}
Upvotes: 0