2023-04-18 14:26:41 +02:00
|
|
|
import {Pipe, PipeTransform} from "@angular/core";
|
|
|
|
import {Level, NumberSize, NumberUtils} from "../number-utils.class";
|
|
|
|
import {DecimalPipe} from "@angular/common";
|
|
|
|
|
|
|
|
@Pipe({name: 'numberPercentage'})
|
|
|
|
export class NumberPercentagePipe implements PipeTransform {
|
|
|
|
decimalPipe: DecimalPipe = new DecimalPipe("en");
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* */
|
|
|
|
transform(value: number | string, ...args: any[]): any {
|
2023-06-09 19:52:10 +02:00
|
|
|
let locale: string = 'en';
|
|
|
|
if (args[0]) {
|
|
|
|
locale = args[0];
|
|
|
|
this.decimalPipe = new DecimalPipe(locale);
|
|
|
|
} else {
|
|
|
|
this.decimalPipe = new DecimalPipe('en');
|
|
|
|
}
|
2023-04-18 14:26:41 +02:00
|
|
|
value = Number.parseFloat(value.toString()) * 100;
|
|
|
|
return this.decimalPipe.transform(value) + '<span class="number-size">%</span>';
|
|
|
|
}
|
|
|
|
}
|