diff --git a/public/views/buyAmazon.html b/public/views/buyAmazon.html
index 8f6b69668..30dadf8c9 100644
--- a/public/views/buyAmazon.html
+++ b/public/views/buyAmazon.html
@@ -42,7 +42,7 @@
ng-attr-placeholder="{{'Amount in USD'}}"
min="0.01"
max="500"
- ng-model="fiat"
+ ng-model="formData.fiat"
ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/"
step="0.01"
autocomplete="off" ignore-mouse-wheel required>
@@ -53,7 +53,7 @@
diff --git a/src/js/controllers/amazon.js b/src/js/controllers/amazon.js
index 564291fbe..954c35c24 100644
--- a/src/js/controllers/amazon.js
+++ b/src/js/controllers/amazon.js
@@ -3,12 +3,13 @@
angular.module('copayApp.controllers').controller('amazonController',
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, externalLinkService, popupService) {
+ $scope.network = amazonService.getEnvironment();
+
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
};
var initAmazon = function() {
- $scope.network = amazonService.getEnvironment();
amazonService.getPendingGiftCards(function(err, gcds) {
if (err) {
popupService.showAlert(err);
@@ -82,7 +83,7 @@ angular.module('copayApp.controllers').controller('amazonController',
});
};
- $scope.$on("$ionicView.enter", function(event, data){
+ $scope.$on("$ionicView.beforeEnter", function(event, data){
initAmazon();
});
});
diff --git a/src/js/controllers/buyAmazon.js b/src/js/controllers/buyAmazon.js
index 70817a1aa..903e2a682 100644
--- a/src/js/controllers/buyAmazon.js
+++ b/src/js/controllers/buyAmazon.js
@@ -4,6 +4,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
function($scope, $log, $timeout, $state, lodash, profileService, bwcError, gettextCatalog, configService, walletService, amazonService, ongoingProcess, platformInfo, externalLinkService, popupService) {
var self = this;
+ var network = amazonService.getEnvironment();
var wallet;
$scope.$on('Wallet/Changed', function(event, w) {
@@ -20,7 +21,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
};
this.confirm = function() {
- var message = gettextCatalog.getString('Amazon.com Gift Card purchase for ${{amount}} USD', {amount: $scope.fiat});
+ var message = gettextCatalog.getString('Amazon.com Gift Card purchase for ${{amount}} USD', {amount: $scope.formData.fiat});
var ok = gettextCatalog.getString('Buy');
popupService.showConfirm(null, message, ok, null, function(res) {
if (res) self.createTx();
@@ -40,7 +41,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
var dataSrc = {
currency: 'USD',
- amount: $scope.fiat,
+ amount: $scope.formData.fiat,
uuid: wallet.id
};
var outputs = [];
@@ -209,7 +210,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
};
$scope.$on("$ionicView.enter", function(event, data){
- var network = amazonService.getEnvironment();
+ $scope.formData = { fiat: null };
$scope.wallets = profileService.getWallets({
network: network,
onlyComplete: true
diff --git a/src/js/controllers/modals/txStatus.js b/src/js/controllers/modals/txStatus.js
index c69e34180..4127d2172 100644
--- a/src/js/controllers/modals/txStatus.js
+++ b/src/js/controllers/modals/txStatus.js
@@ -3,11 +3,14 @@
angular.module('copayApp.controllers').controller('txStatusController', function($scope, $timeout, $state, $ionicHistory, $log, addressbookService) {
if ($scope.cb) $timeout($scope.cb, 100);
+ $scope.fromSendTab = $ionicHistory.viewHistory().backView.stateName === "tabs.send.amount";
$scope.cancel = function() {
- $ionicHistory.removeBackView();
- $state.go('tabs.home');
$scope.txStatusModal.hide();
+ if ($scope.fromSendTab) {
+ $ionicHistory.removeBackView();
+ $state.go('tabs.home');
+ }
};
$scope.save = function(addressbookEntry) {
@@ -23,7 +26,6 @@ angular.module('copayApp.controllers').controller('txStatusController', function
});
}
- $scope.fromSendTab = $ionicHistory.viewHistory().backView.stateName === "tabs.send.amount";
addressbookService.list(function(err, ab) {
if (err) $log.error(err);
if (ab[$scope.tx.toAddress]) {