angular-dynamic-number icon indicating copy to clipboard operation
angular-dynamic-number copied to clipboard

num-fixed as option (not filter)

Open slillo opened this issue 8 years ago • 7 comments

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)?

slillo avatar Dec 09 '16 14:12 slillo

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

uhlryk avatar Dec 12 '16 20:12 uhlryk

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

slillo avatar Dec 13 '16 14:12 slillo

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

uhlryk avatar Dec 13 '16 21:12 uhlryk

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

slillo avatar Dec 14 '16 12:12 slillo

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

slillo avatar Dec 15 '16 12:12 slillo

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

uhlryk avatar Dec 15 '16 21:12 uhlryk

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

uhlryk avatar Dec 15 '16 21:12 uhlryk