I am trying to create custom directive for decimal format using angularjs and here is the fiddle.(http://jsfiddle.net/4HRJu/18/)
It's working fine from model to view,but when I try to update the input in the view it's not formatting from view to model.Please correct me what went wrong?
-
can you explain the behavior you're wanting? Are you specifically wanting a rounding input box? if so, are you expecting it to allow anything and then update the value in the box itself, or just update the value of the scope variable? Should it update on blur, or after a certain amount of time without entry?Mike– Mike2014-10-24 19:00:25 +00:00Commented Oct 24, 2014 at 19:00
-
If valid input is entered it should automatically format the input.Actually I heard that parsers function can be used to achieve this, please let me know the difference between parsers and blur functions when to use which function.user2580179– user25801792014-10-25 10:02:38 +00:00Commented Oct 25, 2014 at 10:02
Add a comment
|
1 Answer
Put a {{decimallength}} in your example HTML, and you'll see that the model value does get updated by your $parser, so the view --> model is fine. $parsers won't help you update the value displayed in the text box. Do that by updating the element's value attribute on blur, or according to your use case.
1 Comment
user2580179
I am little bit confused and can you update in the fiddle what you said?