I'm using Angular 9
In one of my components, I'm using Currency Formatting as bellow:
import { formatCurrency } from '@angular/common';
formatCurrency(23456, 'de-DE', '$')
Here, if I pass de-DE as culture, I'm getting error as below:
Missing locale data for the locale "de-DE"
But, if I pass the culture as en-DE, it's working fine.
What's the issue here? Please help in this.
By default angular only contains the locale data for English.
You will need to import and register the correct locale if you want it to work.
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import localeDeExtra from '@angular/common/locales/extra/de';
registerLocaleData(localeDe, 'de-DE', localeDeExtra);
then you should be able to use it.
It would make most sense to register the locale inside your app.module.ts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With