How to get specific currency symbol(rupee symbol in my case) in angular js instead of the default one (dollar $ symbol)

前端 未结 11 1447
野性不改
野性不改 2020-12-13 06:29

When i use \'currency\' in angular js, I am getting a dollar symbol. How to get required currency symbols based on the requirements. As if now i need to know how to display

相关标签:
11条回答
  • 2020-12-13 07:01

    Currency pipe has 3 parameters

    1. Desire currency code.

    .

    2. A Boolean value to indicate whether to display the currency symbol.

    .

    3. Digit info(has 3 parts): consist of minimum number of integer digit, minimum number of fractional digit and maximum number of fractional digit.
    <span>{{value| currency:'1':2:'3'}}</span>
    

    Example

    <span>{{9.667| currency:'USD':true:'2.2-3'}}</span>
    

    Output

    $09.667

    Refer for more details: https://angular.io/api/common/CurrencyPipe

    For currency code: https://en.wikipedia.org/wiki/ISO_4217

    If you want to show the currency in Indian rupee. use code INR

    <span>{{100| currency:'INR':true}}</span>
    

    Output

    ₹100.00

    0 讨论(0)
  • 2020-12-13 07:05

    You can use the symbol parameter:

    Item Price<span style="font-weight:bold;">{{item.price | currency[:symbol]}}</span>
    

    Exemple:

    Item Price<span style="font-weight:bold;">{{item.price | currency:"USD$"}}</span>
    

    Please refer to this:

    http://docs.angularjs.org/api/ng.filter:currency
    
    0 讨论(0)
  • 2020-12-13 07:05

    The currency symbol can be changed from the default $ symbol to something else as follows:
    In HTML Template Binding

     {{ currency_expression | currency[:symbol] }} 
    

    In JavaScript

     $filter('currency')(amount[, symbol]) 
    

    We can display rupee symbol(in this case) for example as follows:
    In HTML Template Binding

    Item Price<span style="font-weight:bold;">{{price | currency:"&#8377;"}}</span> 
    

    OR

    In JavaScript

    $scope.price=$filter('currency')($scope.price,"&#8377;")
    

    Also, we can add a text rather than a symbol if needed as follows:

    Item Price<span style="font-weight:bold;">{{price | currency:"rupee"}}</span> 
    

    Note: Copying rupee symbol directly into HTML will not work.

    See AngularJS currency documentation

    0 讨论(0)
  • 2020-12-13 07:09

    To display currency symbol in angular js you need provide HTML entity for currency symbols below are the examples and usage in through code and in template :

    Inside your Template example of Euro:

    Item Price<span style="font-weight:bold;">{{price | currency:"&euro;"}}</span>
    

    example of Rupee:

    Item Price<span style="font-weight:bold;">{{price | currency:"&#8377;"}}</span>
    

    Also check below url

    http://www.cs.tut.fi/~jkorpela/html/euro.html

    From controller :

    Inject $filter in your controller

    $scope.price=$filter('currency')($scope.price,'&euro;')
    
    0 讨论(0)
  • 2020-12-13 07:11

    See: http://docs.angularjs.org/api/ng.filter:currency

    Simple with:

    currency:"USD$"
    

    and instead of USD$ use what ever you want

    0 讨论(0)
提交回复
热议问题