@owstack/ows-wallet-applet-coinbase
Version:
An OWS Wallet applet plugin for Coinbase.
48 lines (37 loc) • 1.36 kB
JavaScript
'use strict';
angular.module('owsWalletPlugin.controllers').controller('AccountCtrl', function($scope, $state, $timeout, $ionicPopup, lodash, coinbaseService, gettextCatalog, popupService, stringUtils) {
var coinbase = coinbaseService.coinbase;
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.account = coinbase.getAccountById(data.stateParams.accountId);
getTransactions();
});
$scope.format = stringUtils.format;
$scope.trim = stringUtils.trim;
$scope.openReceive = function() {
$scope.account.createAddress().then(function(address) {
$scope.address = address;
$scope.popupState = 'warning';
$scope.receivePopup = $ionicPopup.show({
cssClass: 'popup-account-receive',
scope: $scope,
templateUrl: 'views/account/receive/receive.html'
});
});
};
$scope.openSend = function() {
$state.go('tabs.account-send', {
accountId: $scope.account.id
});
};
function getTransactions() {
$scope.account.getTransactions().then(function(transactions) {
$scope.transactions = transactions;
$scope.$apply();
}).catch(function(error) {
popupService.showAlert(
gettextCatalog.getString('Uh oh!'),
gettextCatalog.getString('Could not get account transactions. Please try again.')
);
});
};
});