PercentPipe
pipe
| npm Package | @angular/common |
|---|---|
| Module | import { PercentPipe } from '@angular/common'; |
| Source | common/src/pipes/number_pipe.ts |
| NgModule | CommonModule |
How To Use
number_expression | percent[:digitInfo[:locale]]
Description
Formats a number as percentage.
-
digitInfoSeeDecimalPipefor detailed description. -
localeis astringdefining the locale to use (uses the currentLOCALE_IDby default)
Example
@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;
}
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v5.angular.io/api/common/PercentPipe