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

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

Open Xteda87 opened this issue 9 years ago • 4 comments

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

Xteda87 avatar Aug 25 '16 12:08 Xteda87

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.

uhlryk avatar Aug 28 '16 13:08 uhlryk

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

Xteda87 avatar Aug 28 '16 15:08 Xteda87

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 avatar Sep 04 '16 08:09 uhlryk

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.

uhlryk avatar Dec 14 '16 21:12 uhlryk