I am using currency pipe in angular2, current I am using
{{price | currency:'USD':true:'1.2-2'}}
which outputs $480,000.00
But The result I want is $480k
, is this possible to achieve?
I end up creating my own custom pipe
@Pipe({
name: 'salePrice'
})
export class PricePipe implements PipeTransform {
transform(input: number): any {
let price: number = input;
if (price > 3000000) {
return '3m+';
}
if (price / 1000 > 1) {
if (price / 1000000 >= 1) {
return parseFloat((price / 1000000).toFixed(3)) + "m";
} else {
return parseFloat((price / 1000).toFixed(2)) + "k";
}
} else {
return price;
}
}
}