ngx-mask
ngx-mask copied to clipboard
Difference between mask directive and pipe when using separator.2
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?
@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.
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)?
any news about this issue?
{{ 1000,05 | mask: 'separator.2' : '.' }}. => 1.000,0
it's not working
@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
@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
Sorry but it doesn't even work in the example...
As I said, I gave up on this lib for monetary value masks!