Open In App

Angular 10 getCurrencySymbol() Method

In this article, we are going to see what is getCurrencySymbol in Angular 10 and how to use it. getCurrencySymbol is used to retrieve the currency symbol for a given currency code

Syntax:



getCurrencySymbol(code, locale, format)

Parameters:

Return Value:



NgModule: Module used by getCurrencySymbol is:

Approach: 

import { LOCALE_ID, NgModule } from '@angular/core';

Example 1:




import {
  getCurrencySymbol
 }
  from '@angular/common';
  
import {Component}
  from '@angular/core';
  
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
curr = getCurrencySymbol("USD", "wide");
}




<h1>
  GeeksforGeeks
</h1>
  
<p>{{curr }} 100</p>

Output:

Example 2:




import {
  getCurrencySymbol
 }
  from '@angular/common';
  
import {Component}
  from '@angular/core';
  
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
curr = getCurrencySymbol("INR", "narrow");
}




<h1>
  GeeksforGeeks
</h1>
  
<p>{{curr }} 304</p>

Output:

Reference: https://angular.io/api/common/getCurrencySymbol


Article Tags :