ngx-currency
ngx-currency copied to clipboard
any possibility to enter negative (-) mark in the input
Hi
First of all, thank you very much for this module, it really helped for me.
I'm having an issue of users always attempting to enter (-) mark when they want to add negative value to input, unfortunately, now users have to add numbers and enter (-) mark towards the end, which is not practical.
Any suggestion or help to sort this out?
Thanks
Hi @slcoder,
At the moment we have the changeToNegative
method that doesn't allow a negative mask to be applyed to a empty rawValue. To make it work we would need a temp attribute to hold the negative decision and apply it to the first number that comes after it, or, we could set a negative default value when the user types the minus button, but that seems odd to me.
I believe we could define that as a feature to be built. (as a config property)
What do you think?
This is the actual method:
changeToNegative(): void {
if (this.options.allowNegative && this.rawValue != "" &&
this.rawValue.charAt(0) != "-" && this.value != 0) {
// Apply the mask to ensure the min and max values are enforced.
this.rawValue = this.applyMask(false, "-" + this.rawValue);
}
}
Hi @nbfontana
Thank you for a prompt response.
Yes, I think your first approach would be handy., Are the changes releasing soon?
--my html---- I have configured my input as :
<input matInput [(ngModel)]="element.amount" currencyMask
[options]="{ allowNegative: true }">
now users able to add minus value into the textbox - this is great
my actual issue is: the user does not allow to enter minus mark at the start of the textbox and enter the value, it only allows enter some value and enter a minus mark, that's is kind of odd practice I believe.
Really appreciate your help on this.
Thanks
I've tried this function and it seems works
changeToNegative() {
if (this.options.allowNegative && this.rawValue != " " && this.rawValue.charAt(0) != "-" && this.value != 0) {
// Apply the mask to ensure the min and max values are enforced.
if (this.rawValue == "" ||this.rawValue == "-"){
this.rawValue ="-"
}else{
this.rawValue = this.applyMask(false, "-" + this.rawValue);
}
}
}
Any news regarding integration of this fix?
In Germany it's typical to type the minus sign at first - so it would be of great help to have this fix or a bybass.
Besides this I'm very happy with ngx-currency because it works perfect for me.
Any update on this, as I also have different geo graphical users requiring the need to enter "-" first before the numeric value?
Any fix to this in the near future?
Any fix to this in the near future?
¿Alguna solución encontrada?, tengo el mismo problema
I've tried this function and it seems works
changeToNegative() { if (this.options.allowNegative && this.rawValue != " " && this.rawValue.charAt(0) != "-" && this.value != 0) { // Apply the mask to ensure the min and max values are enforced. if (this.rawValue == "" ||this.rawValue == "-"){ this.rawValue ="-" }else{ this.rawValue = this.applyMask(false, "-" + this.rawValue); } } }
where to put this function, please?
hello! any updates on this?
bump
Hi! Any updates? I also need that.
Partially solved by https://github.com/nbfontana/ngx-currency/pull/99 and added to a new 3.0.0
npm version.
Will prob generate side-effects. It works like a charm with the default FINANCIAL
input mode, but we prob see more bugs with the other type