PercentPipe

pipe

npm Package @angular/common
Module import { PercentPipe } from '@angular/common';
Source common/src/pipes/number_pipe.ts
NgModule CommonModule

Formats a number as a percentage according to locale rules.

How To Use

number_expression | percent[:digitInfo]

Description

Formats a number as percentage.

WARNING: this pipe uses the Internationalization API which is not yet available in all browsers and may require a polyfill. See Browser Support for details.

Example

@Component({
  selector: 'percent-pipe',
  template: `<div>
    <p>A: {{a | percent}}</p>
    <p>B: {{b | percent:'4.3-5'}}</p>
  </div>`
})
export class PercentPipeComponent {
  a: number = 0.259;
  b: number = 1.3495;
}

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/common/PercentPipe