且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular2在自定义管道中使用基本管道

更新时间: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';