如何为 Angular 2.0 中的数字设置语言环境 [英] How to set locale for numbers in angular 2.0

查看:12
本文介绍了如何为 Angular 2.0 中的数字设置语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

瑞士德语中的数字格式类似于100'000.00"(不是100,000.00").我该如何改变呢?我尝试将 number_pipe.js 中的设置从 en-US 更改为 de-CH,但没有成功.

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?

推荐答案

尝试使用 locale-number.pipe.ts

Try using the locale-number.pipe.ts or

您可以基于 NumeralJs 创建一个简单的管道来格式化数字

you could create a simple pipe based on NumeralJs to format numbers

https://github.com/adamwdraper/Numeral-js

这篇关于如何为 Angular 2.0 中的数字设置语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆