How to set locale for numbers in angular 2.0

surfspider picture surfspider · Jun 7, 2016 · Viewed 21.1k times · Source

The number format in Swiss German is like "100'000.00" (not "100,000.00"). How can I change that? I tried to change the settings in number_pipe.js from en-US to de-CH without success.

var defaultLocale: string = 'de-CH';

Is there a workaround or do I have to implement my own pipe?

Answer

mikevinmike picture mikevinmike · Mar 29, 2017

If you only need one locale for your app, you can as of now (@angular ~2.4.0) register the locale provider in @NgModule.

@NgModule({
    ...
    providers: [
        {provide: LOCALE_ID, useValue: "de-CH"}
    ]
})
export class AppModule {}