Angular 15.1.3 Node 18.11.9 ng2-currency-mask ^13.0.3
ng2-currency-mask allows you to format numbers with current, rate with any prefix or suffix you want to add and also custom scaling and format.
When dealing with negative values, it has a limitation, it would allow - only when you have entered any digit, it won't allow you to enter - on a empty text field.
I tried creating a directive on keydown to allow - when values is empty, still no luck.
Is there any way to allow - before entering the digits?
If not, what is the alternative I can use for the above requirements?
Angular 15.1.3 Node 18.11.9 ng2-currency-mask ^13.0.3
ng2-currency-mask allows you to format numbers with current, rate with any prefix or suffix you want to add and also custom scaling and format.
When dealing with negative values, it has a limitation, it would allow - only when you have entered any digit, it won't allow you to enter - on a empty text field.
I tried creating a directive on keydown to allow - when values is empty, still no luck.
Is there any way to allow - before entering the digits?
If not, what is the alternative I can use for the above requirements?
Share Improve this question asked Feb 5 at 17:02 Deepak LalithkumarDeepak Lalithkumar 233 bronze badges1 Answer
Reset to default 0Considering that ng2-currency-mask
isn't being maintained very regularly (with the most recent version being over 3 years old now), it might be worth looking for alternatives such as ngx-mask
(NPM entry)
In their documentation, there is an explicit paragraph about allowing negative numbers link, search for "negative"
<input type='text' mask="0000" [allowNegativeNumbers]="true">
Disclaimer: I have not tried this project nor am I affiliated with it, but it looks to solve your issue since the directive approach isn't working and the repo isn't being maintained either.