If any one looking same in angular 2 then here is solution ,
1.Create custom pipe
2.Use in your html pipe code
1.Create custom pipe .
Create file indianCurrency.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'indianCurrency'})
export class IndianCurrency implements PipeTransform {
transform(value: number, args: string[]): any {
if (! isNaN(value)) {
var currencySymbol = '₹';
//var output = Number(input).toLocaleString('en-IN'); <-- This method is not working fine in all browsers!
var result = value.toString().split('.');
var lastThree = result[0].substring(result[0].length - 3);
var otherNumbers = result[0].substring(0, result[0].length - 3);
if (otherNumbers != '')
lastThree = ',' + lastThree;
var output = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
if (result.length > 1) {
output += "." + result[1];
}
return currencySymbol + output;
}
}
}
Indian rupee follows different format compare to US currency; So, don't use default angular currency filter to format Indian Rupees
Custom INR Currency Filter
var app = angular.module('app', []);
app.controller('indexCtrl', function ($scope) {
$scope.amount = 10000000.33;
});
app.filter('INR', function () {
return function (input) {
if (! isNaN(input)) {
var currencySymbol = '₹';
//var output = Number(input).toLocaleString('en-IN'); <-- This method is not working fine in all browsers!
var result = input.toString().split('.');
var lastThree = result[0].substring(result[0].length - 3);
var otherNumbers = result[0].substring(0, result[0].length - 3);
if (otherNumbers != '')
lastThree = ',' + lastThree;
var output = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
if (result.length > 1) {
output += "." + result[1];
}
return currencySymbol + output;
}
}
});
If any one looking same in angular 2 then here is solution , 1.Create custom pipe 2.Use in your html pipe code
1.Create custom pipe .
Create file indianCurrency.pipe.ts
Declare in app.module.ts
2.Use in your html
You can format currency in INR with using pipe and even removing decimal value (i.e Paise) like
this code will work for ionic3 also
For display amount with two digits after decimal ...
Try this:
I know it's a bit late, but you can just use https://osrec.github.io/currencyFormatter.js/ which handles
Then all you need is:
Indian rupee follows different format compare to US currency; So, don't use default angular currency filter to format Indian Rupees
Custom INR Currency Filter