Wallet/src/js/controllers/addressbookView.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-09-12 11:57:20 -03:00
'use strict';
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, $stateParams, lodash, addressbookService, popupService, $ionicHistory) {
2016-09-12 11:57:20 -03:00
$scope.$on("$ionicView.beforeEnter", function(event, data){
var address = data.stateParams.address;
2016-09-12 11:57:20 -03:00
if (!address) {
$ionicHistory.back();
2016-09-12 11:57:20 -03:00
return;
}
addressbookService.get(address, function(err, obj) {
if (err) {
popupService.showAlert(err);
return;
}
if (!lodash.isObject(obj)) {
var name = obj;
obj = {
'name': name,
'address': address,
'email': ''
};
}
$scope.addressbookEntry = obj;
$timeout(function() {
$scope.$apply();
});
});
2016-09-12 11:57:20 -03:00
});
$scope.sendTo = function() {
$ionicHistory.removeBackView();
$state.go('tabs.send');
2016-09-12 11:57:20 -03:00
$timeout(function() {
$state.transitionTo('tabs.send.amount', {
2016-09-12 11:57:20 -03:00
toAddress: $scope.addressbookEntry.address,
2016-09-16 21:01:19 -03:00
toName: $scope.addressbookEntry.name,
toEmail: $scope.addressbookEntry.email
2016-09-12 11:57:20 -03:00
});
}, 100);
};
});