Numbers
formatFraction
Approximate finite values as localized bounded-denominator fractions.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { FormatFractionPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [FormatFractionPipe],
template: `{{ 1.5 | formatFraction: 100 }}`,
})
export class ExampleComponent {
}
Template
{{ 1.5 | formatFraction: 100 }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
Ordered parameters: maximumDenominator. Locale is controlled separately.
Applied to the live output.
Live template data
readonly value = 1.5;
readonly parameter0 = 100;
{{ value | formatFraction: parameter0: "en-US" }}
Rendered output
3/2