0

I'm trying to get write access of <input type="date" min attribute within my custom directive value. As I know input[date] element is directive to. https://docs.angularjs.org/api/ng/input/input%5Bdate%5D So access by $(elem).attr('min') is not right way. How can I access input[date] min attribute within my directive?

JsFiddle here: http://jsfiddle.net/musuk/Lbbtyjod/

1 Answer 1

2

DEMO

As per your directive:

use attrs.myDirective to access minvalue inside your directive link function. To access min date: attrs.min and to set min date attrs.$set('min', '2015-03-02')

.directive("myDirective", function(){
   return {
      require: 'ngModel',
       scope: {
           minValue: "=myDirective"
       },
      link: function(scope, element, attrs) {
          scope.$watch('minValue', function(){
              console.log(attrs.myDirective);
              // Set min here
              attrs.$set('min', '2015-03-02');
          });
      }
    };
});
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.