Wallet/js/controllers/home.js

33 lines
819 B
JavaScript
Raw Normal View History

2014-03-26 09:18:42 -03:00
'use strict';
angular.module('copay.home').controller('HomeController',
2014-04-18 19:08:01 -03:00
function($scope, $rootScope, controllerUtils) {
2014-03-26 09:18:42 -03:00
$scope.title = 'Home';
2014-03-26 18:07:28 -03:00
$scope.oneAtATime = true;
2014-04-16 18:01:37 -03:00
$scope.addrBalance = {};
2014-03-26 18:07:28 -03:00
2014-04-18 13:20:35 -03:00
var w = $rootScope.wallet;
2014-04-18 13:20:35 -03:00
var _updateBalance = function () {
w.getBalance(function (balance, balanceByAddr) {
2014-04-18 19:08:01 -03:00
$rootScope.$apply(function() {
$rootScope.balanceByAddr = balanceByAddr;
$scope.addrs = Object.keys(balanceByAddr);
$scope.selectedAddr = $scope.addrs[0];
});
2014-04-18 13:20:35 -03:00
});
};
$scope.newAddr = function() {
2014-04-18 19:08:01 -03:00
w.generateAddress().toString();
2014-04-18 13:20:35 -03:00
_updateBalance();
2014-04-18 19:08:01 -03:00
controllerUtils.setSocketHandlers();
};
$scope.selectAddr = function(addr) {
$scope.selectedAddr = addr;
};
2014-04-18 13:20:35 -03:00
_updateBalance();
2014-03-26 09:18:42 -03:00
});