abstra-docs
Search…
⌃K

Formating numbers

Sometimes, you need to display numbers with distinct formats

Decimal places

If you need set a fixed number of decimal places, you can toggle JS mode and then usd toFixed method from Javascript.
The variable/data type should be number, otherwise the method toFixed will not be available.
Example on adding decimal places on number display

Using commas

Once you are in Javascript mode, you can always replace characters, like that:
$.salary.toFixed(2).replace(/\./g, ',')

Using other formats

Additionally, you can use toLocaleString
$.salary.toLocaleString("pt-BR", {style: "currency", currency: "BRL"})
// "R$ 12.000,00"