Yuniku_123
Yuniku_123

Reputation: 279

How to format a number in template?

Since the Angular 2 documentation is really poor, I have a question:

I have a number:

{{ -1739034 | percent : '1.2-2'}} and it is displayed as : -1,739,034.

How can I transform it into -1'739'034?

Thanks!

Upvotes: 0

Views: 705

Answers (1)

Dhruvan Ganesh
Dhruvan Ganesh

Reputation: 1570

Try using locale-number.pipe.ts -- it modifies the pipes from angular 2 to take an additional parameter for setting the locale

The locale you are looking for is de-CH (Switzerland)

Try number.toLocaleString('de-CH', { style: 'decimal' }) and verify for yourself

Upvotes: 1

Related Questions