Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
902 B

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Sebastian Stehle. All rights reserved
*/
import { Pipe } from '@angular/core';
import { CurrencyConfig, DecimalSeparatorConfig } from './../configurations';
@Pipe({
name: 'money'
})
export class MoneyPipe {
constructor(
private readonly currency: CurrencyConfig,
private readonly separator: DecimalSeparatorConfig
) {
}
public transform(value: number, args: string[]): any {
const money = value.toFixed(2).toString();
let result = money.substr(0, money.length - 3) + this.separator.value + '<span class="decimal">' + money.substr(money.length - 2, 2) + '</span>';
if (this.currency.showAfter) {
result = result + ' ' + this.currency.symbol;
} else {
result = this.currency.symbol + ' ' + result;
}
return result;
}
}