Why is Angular number pipe output different from Intl.NumberFormat.format()?

Viewed 931

I'm experiencing different output when using number pipe compared to a custom Intl.NumberFormat event thought I have specified the locale to use.

Let's say I have the number x = 1234.56 and I want to output it.

Number pipe returns 1,234.56

{{x | number:'1.2-2':'de-CH'}}

Intl.NumberFormat returns 1’234.56

twoFractionDigitNumberFormat = new Intl.NumberFormat('de-CH', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
{{twoFractionDigitNumberFormat.format(x)}}

I've set up jsfiddle to show the different output: https://jsfiddle.net/2xs4t50y/1/

I know I could create a custom pipe which replaces the , with a ', but I'd like to know from where this difference comes and ideally how I can fix it besides with string replacements. If I'm informed correctly, the number pipe also uses the internationalization api under the hood.

0 Answers
Related