PercentPipe
pipe
Transforms a number to a percentage string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.
transform
3 overloads@paramvalue
string | number
@paramdigitsInfo
string | undefined
@paramlocale
string | undefined
@returns
string | null
@paramvalue
null | undefined
@paramdigitsInfo
string | undefined
@paramlocale
string | undefined
@returns
null
@paramvalue
string | number | null | undefined
@paramdigitsInfo
string | undefined
@paramlocale
string | undefined
@returns
string | null
Description
Transforms a number to a percentage string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.
Exported by
Usage Notes
The following code shows how the pipe transforms numbers
into text strings, according to various format specifications,
where the caller's default locale is en-US
.
@Component({ selector: 'percent-pipe', template: `<div> <!--output '26%'--> <p>A: {{ a | percent }}</p> <!--output '0,134.950%'--> <p>B: {{ b | percent: '4.3-5' }}</p> <!--output '0 134,950 %'--> <p>B: {{ b | percent: '4.3-5' : 'fr' }}</p> </div>`, standalone: false,})export class PercentPipeComponent { a: number = 0.259; b: number = 1.3495;}
Jump to details