Wallet/js/controllers/paymentIntent.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
2014-11-29 18:35:48 -03:00
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, balanceService) {
$scope.wallets = [];
2014-11-15 03:26:22 -03:00
$rootScope.title = 'Payment intent';
2014-11-29 18:35:48 -03:00
$scope.wallets = rootScope.iden.listWallets();
2014-11-06 12:47:54 -03:00
2014-11-29 18:35:48 -03:00
var l = $scope.wallet.length;
_.each($scope.wallets, function(w, i) {
balanceService.update(w, function(){
if (i === l-1)
2014-11-04 17:18:15 -03:00
$rootScope.$digest();
2014-11-29 18:35:48 -03:00
});
});
2014-11-04 15:24:56 -03:00
$scope.open = function() {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
items: function() {
return $scope.wallets;
}
}
});
};
// Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above.
2014-11-29 18:35:48 -03:00
var ModalInstanceCtrl = function($scope, $modalInstance, items, identityService) {
2014-11-04 15:24:56 -03:00
$scope.wallets = items;
$scope.ok = function(selectedItem) {
2014-11-29 18:35:48 -03:00
identityService.setPaymentWallet(selectedItem);
2014-11-04 15:24:56 -03:00
$modalInstance.close();
};
$scope.cancel = function() {
2014-11-05 16:37:25 -03:00
$rootScope.pendingPayment = null;
2014-11-06 11:17:05 -03:00
$location.path('/');
2014-11-05 16:37:25 -03:00
$modalInstance.close();
2014-11-04 15:24:56 -03:00
};
};
});