In Angular, CurrencyPipe helps format numbers into currency values based on local conventions. Here's how to use it:
Basic Usage
In Component Template
<!-- Default currency (USD) with symbol -->
<p>{{ amount | currency }}</p>
<!-- Specific currency code -->
<p>{{ amount | currency:'EUR' }}</p>
<!-- With display format -->
<p>{{ amount | currency:'CAD':'symbol':'1.2-2' }}</p>
In Component Class
import { CurrencyPipe } from '@angular/common';
constructor(private currencyPipe: CurrencyPipe) {}
formatCurrency(value: number, currencyCode: string): string {
return this.currencyPipe.transform(value, currencyCode, 'symbol', '1.2-2');
}