0

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?

2
  • 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? Commented 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. Commented Oct 25, 2014 at 10:02

1 Answer 1

1

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.

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

1 Comment

I am little bit confused and can you update in the fiddle what you said?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.