Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngModel: force running formatters for custom things #12815

Closed
aleksanyan opened this issue Sep 10, 2015 · 1 comment
Closed

ngModel: force running formatters for custom things #12815

aleksanyan opened this issue Sep 10, 2015 · 1 comment

Comments

@aleksanyan
Copy link

Hello,

I am working on the application, where I have input field with ng-model, inside which I need to show number in different units ata time (like px or %),
From the application point of view it is convenient to keep single unit in the model for calculations (i.e model contains only px values), and show different units in input field with help of parsers and formatters. I also have a toggle button for changing the unit.

The problem is , when I try to change the unit, I need formatters to run and store different viewValue inside input field (like instead of px value, show % value in input, though model still has px value).
I did not find any good way of doing this.
I end up incrementing my px value, and in $timeout decrement again, which runs second digest, and causes unwanted UI behaviour (like if model value is binded to something else, it will increment and decrement in few milliseconds, but you can still notice it).

Can we have an api which will trigger formatters for ngModelController and update view value?

@Narretz
Copy link
Contributor

Narretz commented Sep 11, 2015

Let's centralize the discussion here: #3407

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants