Implementing a value calculator on the client side using AngularJS. I need to update the main value of the calculator every 5 minutes with setInterval().
This is my AngularJS code:
$http({method: 'GET', url: '../assets/sources.json'}).success(function(data)
{
$scope.values = data; // response data
$scope.getSourceValue = function(){
if ($scope.source == "test") {
return $scope.values.test["last"]
} else if ($scope.source == "test"){
return $scope.values.test1["last"]
} else if ($scope.source == "test2"){
return $scope.values["test2"]["last"]
} else {
return -1
};
} // getSource
}
In the client side:
<strong><h1> {{getSourceValue()|currency}}</strong></h1>
Any guidance would be greatly appreciated.
Thank you in advance.
UPDATE:
{
"timestamp": "Sun Sep 14 2014, 01:40:03",
"bitstamp": {
"display_URL": "http://www.bitstamp.net",
"display_name": "Bitstamp",
"currency": "BTC",
"last": 477.6
},
"btc-e": {
"display_URL": "http://www.btc-e.com",
"display_name": "BTC-e",
"currency": "BTC",
"last": 471.5
},
"bitcoinaverage": {
"display_URL": "http://api.bitcoinaverage.com",
"display_name": "BitcoinAverage",
"currency": "BTC",
"last": 479.23
},
"geeklab": {
"display_URL": "http://ws.geeklab.com.ar",
"display_name": "Geeklab",
"currency": "ARS",
"blue": 14.35
}
}