I'm using the money.js and accounting.js libraries. I used npm install to get them in package.json and am referencing them in my JS file like:
var fx = require("money");
var accounting = require("accounting");
however the functions included in the library are not recognized, and angular cannot load - so I think I must be doing this incorrectly.
This is how it's being used:
var fx = require("money");
var accounting = require("accounting");
const USD = "USD";
const GBP = "GBP";
const EUR = "EUR";
fx.base = USD;
var response = $http.get("http://api.fixer.io/latest");
response.then(function(response){
fx.rates = response.data.rates;
}, function(error){
//handle error
});
...
$scope.getTotalGBP = () => {
var price = $scope.getTotalPrice();
var priceGBP = fx.convert(price).from(USD).to(GBP);
var formatted = accounting.formatMoney(priceGBP, [symbol = "£"], [precision = 2], [thousand = ","], [decimal = "."], [format = "%s%v"]);
return formatted;
};