angular 数字逗号分隔,如何在Angular 4中为数字管道指定区域设置千位分隔符

在Angular 4中,若要更改数字管道(number pipe)的默认千位分隔符,可以创建自定义管道。在Angular 5+版本中,可以通过设置locale参数来直接指定,如`number:'':'fr-FR'`。但在早期版本中,由于没有提供直接修改字符的方法,需要创建名为`numberfr`的自定义管道来处理特殊格式需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How can I specify/override default (locale) thousand separator for number pipe in Angular 4, e.g.?

{ {p.total | number}}

?

解决方案

Angular 5+

Since Angular 5, a locale argument has been added to the decimal pipe as you can see in the official documentation: https://angular.io/api/common/DecimalPipe. That means you can choose your locale directly while calling the pipe, for instance:

{ {p.total | number:'':'fr-FR'}}

Just be aware that will also change the decimal separator.

Angular 2+

or if your want to change ONLY the thousands separator...

According to Angular's documentation on DecimalPipe : https://v2.angular.io/docs/ts/latest/api/common/index/DecimalPipe-pipe.html, there is no explicit argument that can be added to the pipe call to exceptionally alter the characters used for

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值