我有一個小問題,如何在數量欄位中用“逗號”替換“點”?

我不想得到587.00,而是想要得到587,00。
我不知道如何轉換這個?
這是我現在的代碼:
HTML
<tr *ngFor="let line of osts">
...
<td scope="row" >{{ line.QUANTITY | variableFormatNum: "1.2-2" }}</td>
...
</tr>
可變格式-num.pipe.ts
import { DecimalPipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'variableFormatNum' })
export class VariableFormatNumPipe implements PipeTransform {
constructor(private decimalPipe: DecimalPipe) {
}
transform(input: number | string | null | undefined, digitsInfo?: string): string | null {
return this.decimalPipe.transform(input, digitsInfo);
}
}
先感謝您。
uj5u.com熱心網友回復:
您正在使用的DecimalPipewhitch 有一個locale可用于顯示“逗號”的引數。
使用例如法語語言環境:
transform(input: number | string | null | undefined, digitsInfo?: string, locale: string = 'fr-FR'): string | null {
return this.decimalPipe.transform(input, digitsInfo, locale);
}
有關更多資訊,請參閱檔案。
在你可以你甚至不需要自定義管道,你可以簡單地DecialPipe直接使用:
<tr *ngFor="let line of osts">
...
<td scope="row" >{{ line.QUANTITY | number:'1.2-2':'fr-FR' }}</td>
...
</tr>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/493806.html
標籤:有角度的
