uhlryk / angular-dynamic-number

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

Can the text box to display a number with 2 digits after the decimal point? #32

Open Xteda87 opened 8 years ago

Xteda87 commented 8 years ago

Hi! Sorry for my bad English.

Actually the problem - I need to output to other inputs of calculation and would like to see the number there were two decimal places

For example 1.10 instead of 1.1 http://screencast.com/t/EwWXrUyIJMb thank you in advance

uhlryk commented 8 years ago

This directive returns number. And therefore even if we return 1.10 then it will be visible as 1.1 . But to this package I also added filters. Filter allow to format output value. There is option to show zeros at the end.

For example this allow to show 1.10 {{value|awnum:2:'.':'round':'true':'true'}}

But Im not sure if it will work in other inputs. If no then you should in controller run filter to other model and new model pass to next input.

Please give me info how you solved it. Or if you have more questions I will help you.

Xteda87 commented 8 years ago

I tried to set the value in the input through the filter, but still zero rounds

input awnum num-int="6" num-thousand-sep="{{' '}}" num-neg="false" num-thousand="true" num-fixed="2" type="text" id="summ" ng-model="life.summ" ng-change="life.changeSumm()" vm.summ = $filter('awnum')(100.30, 2,'.','round','true','true');

http://screencast.com/t/GOEMQIfcG1

Upd. the string is returned in the text field? If yes, then it may check for decimal separator characters. If 1, then at the end adding 0

uhlryk commented 8 years ago

Ok, now I understand. Other input is also angular-dynamic-number.

Unfortunately right now it is impossible to set leading and trailing zeros.

Very likely this functionality may be very interesting in this module. I need to think a little about it (behavior of cursor and UX). Maybe I will implement this functionality.

Thanks for this great idea. I will let you know what I decided.

uhlryk commented 7 years ago

In latest version input with num-fixed equal true, shows what you want. I didn't tested if this can be value from other directive. Please check it.