Cast number type to BigDecimal TypeScript ( Angular)

Viewed 14623

I need to send a BigDecimal value from my angular front-end part to the java back-end. I tried to find a valuable solution but it seems that TypeScript knows only number type.

Is there any way to declare/cast a BigDecimal attribute in my angular project?

private totalPrice: number;
1 Answers

After couple of libraries tried, big.js seems the best:

Install the library using the following command in root folder:

$ npm install --save big.js

Import:

import Big from 'big.js';

Use:

private totalPrice: any;
this.totalPrice = Big(number_value).toPrecision(2) --> (e.g. 15.00)
Related