I would like to create an Angular 5 pipe that translates a more readable fraction from a number.
For example:
0,66 -> ⅔
0,25 -> ¼
1.25 -> 1 ¼
Here is what I already have, but I would like to make it more dynamic:
export class FracturePipe implements PipeTransform {
transform(value: any, args?: any): any {
let roundedValue = Math.round(Number(value) * 100) / 100
if (roundedValue === 0.66) {
return '⅔'
}
//..and so on, but maybe there is a better way
}
}
Any ideas how to do that in a more dymamic way?