Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Angular10 getNumberOfCurrencyDigits() Function

  • Last Updated : 30 Apr, 2021

In this article, we are going to see what is getNumberOfCurrencyDigits in Angular 10 and how to use it.

The getNumberOfCurrencyDigits is used to get the number of decimal digits for a given currency.


getNumberOfCurrencyDigits(code: string): number

NgModule: Module used by getNumberOfCurrencyDigits is:

  • CommonModule


  • Create the angular app to be used
  • In app.module.ts import LOCALE_ID because we need locale to be imported for using get getNumberOfCurrencyDigits.
import { LOCALE_ID, NgModule } from '@angular/core';
  • In app.component.ts import getNumberOfCurrencyDigits 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.


  • code: the currency code

Return value:

  • number: The number of decimal digits.

Example 1:


import { LOCALE_ID, NgModule } 
        from '@angular/core';
import { BrowserModule } 
        from '@angular/platform-browser';
import { AppRoutingModule } 
        from './app-routing.module';
import { AppComponent }
        from './app.component';
  declarations: [
  imports: [
  providers: [
      { provide: LOCALE_ID, useValue: 'en-GB' },
  bootstrap: [AppComponent]
export class AppModule { }


import {FormStyle,
        from '@angular/common';
import {Component, 
        LOCALE_ID } 
        from '@angular/core';
    selector: 'app-root',
    templateUrl: './app.component.html'
export class AppComponent {
    for = getNumberOfCurrencyDigits(this.locale);
        @Inject(LOCALE_ID) public locale: string,){}


<p>currency digit number is: {{for}}</p>



My Personal Notes arrow_drop_up
Recommended Articles
Page :