number in <input>
element formatted by this.decimalPipe.transform(...)
User changed value, then I need get this string value from input element and convert it back to number for further actions.
How to do reverse operation - convert string back from decimalPipe result to number?
Asked
Active
Viewed 1,912 times
3

Pranay Rana
- 175,020
- 35
- 237
- 263

ildar
- 101
- 7
-
inputFiled.Value may be '1,234.56' or '1.234,56' or something else - it depends on Angular LOCALE_ID. Please dont answers like parseFloat, Number() etc. – ildar Apr 03 '18 at 14:07
-
so I guess Angular dosn't have such feature... – ildar Apr 03 '18 at 14:08
1 Answers
1
The best option for me is to use: ng2-currency-mask directive for clean coding.
<input currencyMask [(ngModel)]="value" [options]="{ prefix: 'R$ ', thousands: '.', decimal: ',', precision: 2 }"/>

developer
- 521
- 1
- 5
- 21