2

I have a simple form with two input boxes of number type. When i try to add max attribute via directive, it seems to ignore it and doesn't validates although attribute is added on the dom element. When i add it inline it works.I referred this question AngularJs can't read dynamically set attributes but that did'nt seemed to help me.New in angularJS and completely clueless.

Any help appreciated.

Edit: Updated fiddle Demo http://jsfiddle.net/tNUNh/6/

1 Answer 1

2

Didn't look furthuer, but one solution you have is to recompile the element everytime you change its max value.

Just change inject $compile (module.directive('type', ['$compile', function ($compile) {) and after attr.$set('max', '100') call $compile(element)(scope).

This doesn't seem right, but I'd need to look further into input directive code to see if it exposes a way to change it without recompiling.

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

4 Comments

hey i updated the fiddle as you suggested and it is causing anomalies. Would you mind looking into this: jsfiddle.net/tNUNh/9
Does any way to get the input directive and relink this element? like this: angular.modules('ng').directive('input').link(scope, element, attrs). the $compile(element)(scope) would be raise recursive error...
@I_Debug_Everything I got it to run (see jsfiddle.net/tNUNh/12). You simply needed to put the $compile inside that "if" statement

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.