Formating string using Numeral.js

201 views Asked by At

How can I format a number respecting the last two number as decimals?

1000 -> 10,00

123456 -> 1.234,56

I am trying the code below but it won't work keeping the last two places as decimals.

fromat(value) {
             return value === null ? "0,00" :  Numeral(value).format('0,0[.]00');
            },

Thank you.

1

There are 1 answers

0
Low Rider On

Here is my solution:

Numeral(`${value.toString().slice(0, -2)}.${value.toString().slice(-2)}`).format('$ 0,0.00')