uhlryk / angular-dynamic-number

Highly customizable angular directive for numbers
64 stars 32 forks source link

num-fixed as option (not filter) #38

Open slillo opened 7 years ago

slillo commented 7 years ago

It's not clear to me how to use numFixed filter in an input field built like this:

<input awnum num-int="6" num-fract="2" num-sep="," num-thousand="true" num-thousand-sep="." num-neg="false" num-round="round" num-pos="true" num-prepend="" num-append="" ng-trim="false" ng-init="moduloCtrl[dynindex] = 2.00" ng-model="moduloCtrl[dynindex]" />

This field will show '2' and not ('2,00').

Debugging dynamic-number.js, in filterModelValue function I can see that numFixed is by default set to false. To obtain the desired result I have to set numFixed variable to true. How I should use numFixed filter in this case? If not possible, is it possible to set the default value of numFixed to true or also better make it work also as option (attribute of input text field)?

uhlryk commented 7 years ago

Hey In previous versions it was impossible. Now it may work. I will check it within a few days

slillo commented 7 years ago

thanks. Here is an example: https://plnkr.co/edit/zenr0zqZF1Q1RGZWsQLx?p=preview

uhlryk commented 7 years ago

Please check latest version, I think I done it. I also used your example with latest source : https://plnkr.co/edit/7Ss7ad0dSOWY7choo7ei?p=preview

slillo commented 7 years ago

Thanks, it works! However in my example awnum was, wrongly, set to 'true'. This triggers the error 'strategy is undefined'

slillo commented 7 years ago

Reopened, because using num-fixed, every value has decimal separator so typing separator is ignored.

https://plnkr.co/edit/7Ss7ad0dSOWY7choo7ei?p=preview

As you can see, user have to manually move after separator using arrow key or clicking. I think that, when separator key is typed, caret should move after decimal separator. I've implemented a solution that seems to work in link function of directive (after comment '//on num-sep move caret after decimal separator'):

https://plnkr.co/edit/8hLWSgeMtfyUABtzLsHK?p=preview

uhlryk commented 7 years ago

Thx for your feedback. Usually new functionality introduce some border cases. I just fixed this one.

uhlryk commented 7 years ago

THere is one issue with fixed option https://github.com/uhlryk/angular-dynamic-number/issues/41 Write what you think about it.