ara*_*b78 1 format pipe angular
我需要格式化一个数字以将点数放入数千个,我需要使用角度 2 中的管道对其进行格式化。Ejem:数字是 1983839,结果必须是 1.983.839 知道吗?
{{amount | number}}
Run Code Online (Sandbox Code Playgroud)
我用这个解决方案解决了这个问题。我使用了提供角度的“DecimalPipe”管道。
我在提供者的 app.module 中添加了我的区域设置并导入了“LOCALE_ID”:
import { LOCALE_ID } from '@angular/core';
providers: [
{ provide: LOCALE_ID, useValue: "es-ES" },
...
]
Run Code Online (Sandbox Code Playgroud)
然后在我的组件中我使用了角度管道“DecimalPipe”:
component.ts:
import { DecimalPipe } from '@angular/common';
component.html:
{{fila.NumeroCopiasBN | Number:'1.0-0' }}
Run Code Online (Sandbox Code Playgroud)
我发送到管道“1.0-0”的参数是一个字符串,其格式如下:
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
| 归档时间: |
|
| 查看次数: |
8699 次 |
| 最近记录: |