Singleton

Version 0.6

One-fits-all Internationalization Solution

Percent Format Pipe

Overview

Formats a number into percentage string. Group sizing and separator and other locale-specific configurations are based on the pattern data.

Usage

{{ value | percentFormat [ : formatOptions ] }}

Parameters

Parameter Type
Description
formatOptions object The results formats can be customized using the formatOptions argument. See formatOptions for further details.

formatOptions

Attribute Type Required
Description
minIntegerDigits number Optional The minimum digits of integer numbers used. The possible values are from 1 to 21, and the default value is 1..
minFractionDigits number Optional The minimum digits of fraction numbers used. The possible values are from 0 to 20, and the default value is 0.
maxFractionDigits number Optional The maximum digits of fraction numbers used. The possible values are from 0 to 20, and the default value is 3.

Example Code

// input '0.1'
{{ num | percentFormat }}
// output '10%'

// input '0.1234'
{{ num | percentFormat }}
// output '12%'

// Format options usages
// Please note that pass object as a parameter,
// the end of the brace should keep a whitespace.

// input '0.1234'
{{ num | percentFormat: { minFractionDigits: 2 } }}
// output '12.34%'

// input '12345'
{{ num | percentFormat }}
// output '1,234,500%'
Last updated on 24 Sep 2019
Published on 24 Sep 2019
 Edit on GitHub