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

前端 未结 11 1454
野性不改
野性不改 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条回答
  •  萌比男神i
    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{{price | currency:"₹"}} 
    

    OR

    In JavaScript

    $scope.price=$filter('currency')($scope.price,"₹")
    

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

    Item Price{{price | currency:"rupee"}} 
    

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

    See AngularJS currency documentation

提交回复
热议问题