Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between mask directive and pipe when using separator.2 #636

Closed
michaelhunziker opened this issue Nov 20, 2019 · 6 comments
Closed

Comments

@michaelhunziker
Copy link

Hi!

When i use the mask "separator.2" on an input i get another result compared to using it with a pipe.

Example: The variable "currency" has the value 3000 (number). The masked input shows "3'000" (which is missing the two decimal places) initially and the pipe shows "3'000.00" (which is correct).

Stackblitz: https://stackblitz.com/edit/ngx-mask

Is there a reason for this?

@isysenko
Copy link
Contributor

@michaelhunziker Hi!
In case <div>CHF {{currency | mask:'separator.2'}}</div> mask applied to value without expect of next input(value is perceived as a constant) and because of that add decimal part.
in case <input matInput mask="separator.2" [(ngModel)]="currency"> output is 3000 because currency is perceived as variable. Decimal part don't add automatical. If input value is 111.11, output - 111.11 . if you try to input 111.111 mask isn't allow you to type last character.
We will discuss this issue and possible mask will be updated.

@lramondev
Copy link

There are several open questions related to the case. Would it be so hard to make the library add .00 when the value is integer (3000)?

@alvarodoune
Copy link

alvarodoune commented Jul 17, 2021

any news about this issue?

{{ 1000,05 | mask: 'separator.2' : '.' }}. => 1.000,0

it's not working

@andriikamaldinov1 andriikamaldinov1 added P0 and removed P2 labels Jun 20, 2023
@andriikamaldinov1
Copy link
Collaborator

@michaelhunziker @lramondev Thanks for your using Ngx-Mask. Please update to latest version.
It example, all work as expected - https://stackblitz.com/edit/angular-z4m8sm?file=src%2Fmain.ts

@andriikamaldinov1
Copy link
Collaborator

@alvarodoune Thanks for your using Ngx-Mask. Please update to latest version.
It example, all work as expected - https://stackblitz.com/edit/angular-svaeeq?file=src%2Fmain.ts

@lramondev
Copy link

lramondev commented Jun 22, 2023

Sorry but it doesn't even work in the example...
As I said, I gave up on this lib for monetary value masks!
Sem título

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants