-
-
Save anonymous/e03de4de1af407bf70f4038acd77c961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.currencyConverter = { | |
getRatio: function(selectedCurrency) { | |
var selectedCurrency = selectedCurrency; | |
$http({ | |
url: 'http://api.fixer.io/latest?base='+selectedCurrency+'&symbols=PLN,CHF,EUR,USD,GBP', | |
method: 'GET' | |
}) | |
.then(function(response) { | |
var currentCurrency = { | |
toPLN: response.data.rates.PLN, | |
toCHF: response.data.rates.CHF, | |
toEUR: response.data.rates.EUR, | |
toUSD: response.data.rates.USD, | |
toUSD: response.data.rates.GBP | |
}; | |
console.log("Succesful store currentCurrency"); | |
return currentCurrency; | |
}, function(response) { | |
console.log("Problem occure while downloading money current currency!"); | |
console.log(response.data); | |
}); | |
}, | |
convertMoney: function(selectedCurrency,priceField) { | |
var priceField = priceField; | |
var selectedCurrency = selectedCurrency; | |
console.log('selectedCurrency in service: '+selectedCurrency); | |
console.log('priceField in service: '+priceField); | |
this.getRatio(selectedCurrency); | |
console.log(currentCurrency); | |
/* | |
var converted = { | |
PLN: function() { return priceField * $rootScope.currentCurrency.toPLN; }, | |
USD: function() { return priceField * $rootScope.currentCurrency.toUSD; }, | |
EUR: function() { return priceField * $rootScope.currentCurrency.toEUR; }, | |
CHF: function() { return priceField * $rootScope.currentCurrency.toCHF; }, | |
GBP: function() { return priceField * $rootScope.currentCurrency.toGBP; } | |
}; | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment