JSFiddle - React, Tailwind, and code Playground
by neptune001
HTML
<div ng-app="AppName">
<div ng-controller="TwoController">
{{totalBalance}} - {{price}} - {{totalValueBtc}}
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular-resource.min.js"></script>
JavaScript
angular.module('AppName', ['ngResource'])
.factory('DogeBalance', ['$resource', function ($resource) {
return $resource("https://dogechain.info/api/v1/address/balance/:address");
}])
.factory('DogePrice', ['$resource', function ($resource) {
return $resource("https://chain.so/api/v2/get_info/DOGE");
}])
.controller('TwoController', function($scope, DogeBalance, DogePrice){
$scope.wallets = [
{ id: 0, type: 'doge', address: 'DT2rmMrutwzdZ8EXwzj4QFdcL6DtvGGkci'},
{ id: 1, type: 'doge', address: 'DMoonjyH1aHLZc1kksmikBUhjXromn1ZN4'}
];
//current price btc/doge
var price = DogePrice.get();
$scope.totalBalance = parseFloat(0);
price.$promise.then(function(data) {
$scope.price = data.data.price;
//aggregate balance on all the addresses
for (i in $scope.wallets){
var balance = DogeBalance.get({address: $scope.wallets[i].address});
balance.$promise.then(function(data) {
$scope.totalBalance += parseFloat(data.balance);
$scope.totalValueBtc = $scope.totalBalance * $scope.price;
});
}
});
});