VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angular-10-formatpercent-method/

⇱ Angular 10 formatPercent() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Angular 10 formatPercent() Method

Last Updated : 23 Jul, 2025

In this article, we are going to see what is formatPercent in Angular 10 and how to use it. formatPercent is used to format a number as a percentage according to locale rules.

Syntax:

formatPercent(value, locale, digitsInfo)

Parameters:

  • value: The number to format.
  • locale: A locale code for the locale format.
  • digitsInfo: Decimal representation options.

Return Value:

  • string: the formatted percent string.

NgModule: Module used by formatPercent is:

  • CommonModule

Approach: 

  • Create the Angular app to be used.
  • In app.module.ts import LOCALE_ID because we need locale to be imported for using get formatPercent.
import { LOCALE_ID, NgModule } from '@angular/core';
  • In app.component.ts import formatPercent and LOCALE_ID
  • inject LOCALE_ID as a public variable.
  • In app.component.html show the local variable using string interpolation
  • Serve the angular app using ng serve to see the output.

Example 1:

Output:

👁 Image

Example 2:

Output:

👁 Image

Example 3:

Output:

👁 Image

Reference: https://v17.angular.io/api/common/formatPercent

Comment

Explore