ildar
ildar

Reputation: 109

Angular 2: decimalPipe result -> convert back to number?

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?

Upvotes: 3

Views: 2116

Answers (1)

developer
developer

Reputation: 521

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 }"/>

Upvotes: 1

Related Questions