When using a numberformatter in JavaScript, is it possible to format the value with the euro sign before the value?
this.formatter = new Intl.NumberFormat('nl-be', {
style: 'currency',
currency: 'EUR',
minimumFractionDigits: 2
});
this.formatter.format(2000);
The code sample from above returns 2000.00€ instead of €2000.00
When using a numberformatter in JavaScript, is it possible to format the value with the euro sign before the value?
this.formatter = new Intl.NumberFormat('nl-be', {
style: 'currency',
currency: 'EUR',
minimumFractionDigits: 2
});
this.formatter.format(2000);
The code sample from above returns 2000.00€ instead of €2000.00
Share Improve this question asked Feb 6, 2018 at 8:59 Dennis SchiepersDennis Schiepers 1371 silver badge12 bronze badges 2- This does not seem to be technically wrong, according to stackoverflow./a/7570778/1427878 And I don’t see Intl.NumberFormat offering any additional options regarding the currency symbol position ... so I guess if you really need this, you will have to manipulate the resulting value yourself somehow. – C3roe Commented Feb 6, 2018 at 9:05
- In Standard Dutch , the currency symbol is always placed before the amount. – Dennis Schiepers Commented Feb 6, 2018 at 9:28
1 Answer
Reset to default 8Two ways:
Use another locale. Here's a list of the supported ones. From there, I took the belgium one (
sfb
), which renders the sign in front of the number.this.formatter = new Intl.NumberFormat('sfb', { style: 'currency', currency: 'EUR', minimumFractionDigits: 2 }); this.formatter.format(2000);
Parse it yourself to move the sign in front of the string:
var str = this.formatter.format(2000); var result = str.substr(str.length-1)+ str.substr(0,str.length-1)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744266631a4565895.html
评论列表(0条)