0

Using ES6 and webpack in my angular project, and trying how to compile a dynamically added angular material directive to my input.

My Directive looks like this

    class addMaxLength {
    constructor() {
        this.restrict = 'A';
        this.scope = {
            maxLength : '='
        };

    }

    // optional link function
    link(scope, element, attributes) {
        if(scope.maxLength > 0){
            element.attr('md-maxlength',scope.maxLength);
        }
    }
}

addMaxLength.$inject = [];

export { addMaxLength };

And trying to see how I can compile the input then to show the new attribute on my input ?

2
  • Can you please go through this answer? Commented Oct 4, 2016 at 10:30
  • Creating a class instead of an object is overhead and has absolutely no value. It's even called directive definition object. Commented Oct 4, 2016 at 10:49

0

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.