INR currency format

2020-02-05 06:42发布

I need to show currency format like these, how can we show.

₹1
₹10
₹100
₹1,000
₹10,000
₹1,00,000
......

17条回答
Evening l夕情丶
2楼-- · 2020-02-05 07:20

You can use this : {{amount:| currency:"₹"}} or you can use hex code for "₹"

Input: {{3*100000000 | currency:"₹"}}

Output: ₹300,000,000.00

查看更多
混吃等死
3楼-- · 2020-02-05 07:21
  1. Get the digits before last three.
  2. Replace the rest of the digits with prefix.replace(/\B(?=(?:\d{2})+(?!\d))/g, ",")
  3. Combine the above section with this modified prefix

Complete explanation on why this regex places commas at the right place is is mentioned here.

查看更多
Root(大扎)
4楼-- · 2020-02-05 07:22

In HTML

{{ currency_expression | currency : symbol : fractionSize}}

for example

{{amount | currency:"₹":0}}

you can also reffer https://docs.angularjs.org/api/ng/filter/currency

查看更多
【Aperson】
5楼-- · 2020-02-05 07:23

Try this one

var x=1000;
x=x.toString();
var lastThree = x.substring(x.length-3);
var otherNumbers = x.substring(0,x.length-3);
if(otherNumbers != '')
    lastThree = ',' + lastThree;
var res = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;

alert(res);
查看更多
你好瞎i
6楼-- · 2020-02-05 07:25

@Pipe({
  name: 'customCurrency'
})
export class CustomCurrencyPipe implements PipeTransform {

  transform(value: number, isSymbol: string, decPointer: string, isPrefix: boolean): string {

    if (!isNaN(value)) {
       var formatted_value;
      var currencyText = isSymbol;
      if (currencyText == '₹') {
        // for Indian number system
        formatted_value = new Intl.NumberFormat('en-IN').format(value)
      }
      else {
        formatted_value = new Intl.NumberFormat().format(value)
      }
      return currencyText + ' ' + formatted_value;
    }
  }

}

HTML

<div>{{ 10000000 | customCurrency:'₹':'1.0':false}}</div>

查看更多
The star\"
7楼-- · 2020-02-05 07:26

Just use INR in currency filter

{{product.product_cost | currency:'INR':true}}
查看更多
登录 后发表回答