Skip to main content

Formatting Pipes

Date Pipe

import { DatePipe } from '@angular/common’;

// Instantiate the pipe
const dtp: DatePipe = new DatePipe('en-US');

// Use the pipe in JS
dtp.transform(self.parAsOfDate, 'M.d.yy');

Number Pipe

import { DecimalPipe } from '@angular/common’;

dp: DecimalPipe = new DecimalPipe('en-US);

// 1.0-8 indicates we can display up to 8 decimal places
this.dp.transform(fieldDetail.value, '1.0-8')

Currency Pipe

import { CurrencyPipe } from '@angular/common’;

cp: CurrencyPipe = new CurrencyPipe('en-US);

// 1.0-8 indicates we can display up to 8 decimal places
this.cp.transform(fieldDetail.value, 'USD', 'symbol', '1.0-8')