更新时间:2023-11-26 16:29:04
您可以扩展CurrencyPipe
,如下所示:
You can extend CurrencyPipe
, something like this:
export class FormatCurrency extends CurrencyPipe implements PipeTransform {
transform(value: any, args: any[]): string {
let formatedByCurrencyPipe = super.transform(value, args);
let formatedByMe;
// do your thing...
return formatedByMe;
}
}
If you look at the source, that's similar to how angular pipes work...
(由问题作者添加)
别忘了导入CurrencyPipe类
Don't forget to import the CurrencyPipe Class
import {CurrencyPipe} from 'angular2/common';