填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

PercentPipe

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.

      
      {{ value_expression | percent [ : digitsInfo [ : locale ] ] }}
    

Exported from

输入值

value string | number

参数

digitsInfo string
可选. 默认值是 `undefined`.
locale string
可选. 默认值是 `undefined`.

参见

使用说明

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>`
})
export class PercentPipeComponent {
  a: number = 0.259;
  b: number = 1.3495;
}