bcherny/format-as-currency

Fix for Custom Currency Symbol

Open

#28 opened on Jun 8, 2017

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (23 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (32 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Hi,

This is not an Issue but a possible fix for a possible issue 😄

In my Angular App i've got a customizable currency symbol and i use a real time database (Firebase).

In your function 'toFloat' from 'formatAsCurrencyUtilities' you provide a solutions only for Dollar Symbol with the RegEx on line 53.

To Avoid error from this i replaced that line with:

    var matchString = 0;
    if (currencyString) matchString = currencyString.match(/(\d|\.)/g).join('');
    return parseFloat(matchString, 10);

With this you can user any filter, with any currency.

Contributor guide