2

I have a custom directive called my-directive which is of attribute type (restrict: 'A'). I use it as follows:

<input my-directive="mydvalue"/>

How do i get the "mydvalue" inside the directive?

app.directive("myDirective", function (){
   return {
      restrict: 'A',
      link: function(scope, el, attrs, controller) {
         //How do i get the mydvalue here.

      }

  };

});
2
  • 5
    Actually attrs.myDirective, but that's the idea. Commented Sep 25, 2013 at 7:56
  • Right, sorry for the mistake :( Commented Sep 25, 2013 at 7:56

1 Answer 1

1

Just attrs.myDirective

In attrs you have all the attributes of the element and a awesome ngModel too :) !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.