ngx-mask icon indicating copy to clipboard operation
ngx-mask copied to clipboard

comma_seperator.2 problem

Open hunterTR opened this issue 5 years ago • 10 comments

[x] Bug ngx-mask v8.0.9 Angular v7.2.0

I am having problem with comma_seperator.2. It doesn't add following 0 to the 1 digit decimal to make it 2 decimal. Input: 1000.1 it render as 1,000.1 It doesn't render as 1,000.10

thanks.

hunterTR avatar Oct 15 '19 16:10 hunterTR

Are you expecting the value you see in the form field to contain the zero on the end? Currently that will just display as .1 but the actual model value that Angular has will contain .10 Note that with latest version the mask has changed to mask="separator.2" and to use a comma you would also pass another attribute thousandSeparator=","

ColinMorris83 avatar Oct 15 '19 17:10 ColinMorris83

What I want to see is 1000.10 on when I patch my form control with a number value 1000.1
thanks.

hunterTR avatar Oct 15 '19 17:10 hunterTR

What I want to see is 1000.10 on when I patch my form control with a number value 1000.1 thanks.

if separator.2 is assigned this would be the correct

lramondev avatar Nov 05 '19 11:11 lramondev

No it doesn't show the extra 0 at the end, if I patch the control with 10.1
separator.2 should add extra one 0 at the end and make it 10.10 in my opinion to make it consistent. For example my forms showing 10.15 in one place and 10.1 in other place. It is not consistent.

hunterTR avatar Nov 07 '19 20:11 hunterTR

Yes. Just like in PHP and

number_format(10.1, 2) // 10.10
number_format(10.1, 2, ',') // 10,10
number_format(1000.1, 2, ',', '.') // 1.000,10

lramondev avatar Nov 08 '19 00:11 lramondev

I can also confirm the issue with trailing zeros.

Example: Input with mask="separator.2" thousandSepartor="," and a value of 18500.1 Expected value: 18,500.10 Current Value: 18,500.1

The control is part of a reactive form.

Can you please elaborate on the usage of the snippet below?

Yes. Just like in PHP and

number_format(10.1, 2) // 10.10

dimmal avatar Dec 12 '19 09:12 dimmal

We are also facing this issue, has anyone found a workaround?

alex87 avatar Feb 18 '21 16:02 alex87

I was forced to go to another library ngx-currency

lramondev avatar Feb 18 '21 20:02 lramondev

We are also facing this issue (using version 11.1.5 and using forms). We've seen that there are 2 closed issues on a similar topic (#267, #307) but we couldn't make it work.

Are there any news on this?

jebner avatar Apr 19 '21 07:04 jebner

any update on this? we are also facing the same issue

nagulapallinaveen avatar Jun 29 '21 13:06 nagulapallinaveen

Any update on this?

Qiric avatar Nov 28 '22 23:11 Qiric

@hunterTR @ColinMorris83 @bgl3317 @nagulapallinaveen @lramondev Thanks for your using Ngx-Mask. Please update to latest version. It example, all work as expected - https://stackblitz.com/edit/angular-xn8sjm?file=src%2Fmain.ts We add leadZero to lead zeros to end of the model

andriikamaldinov1 avatar Jun 08 '23 16:06 andriikamaldinov1

@andriikamaldinov1 Is there any way to keep the decimal places inside the input to display it to the user?

lucasousi avatar Sep 06 '23 21:09 lucasousi