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

Difference between mask directive and pipe when using separator.2

Open michaelhunziker opened this issue 4 years ago • 3 comments

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 avatar Nov 20 '19 19:11 michaelhunziker

@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.

isysenko avatar Dec 25 '19 13:12 isysenko

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)?

lramondev avatar Jan 16 '20 20:01 lramondev

any news about this issue?

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

it's not working

alvarodoune avatar Jul 17 '21 17:07 alvarodoune

@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 avatar Jun 22 '23 13:06 andriikamaldinov1

@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

andriikamaldinov1 avatar Jun 22 '23 13:06 andriikamaldinov1

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

lramondev avatar Jun 22 '23 13:06 lramondev