added the import method

This commit is contained in:
Mario Colque 2014-04-25 19:12:13 -03:00
commit 69e1bb8e37
2 changed files with 38 additions and 11 deletions

View file

@ -1,6 +1,22 @@
'use strict';
angular.module('copay.import').controller('ImportController',
function($scope, $rootScope) {
function($scope, $rootScope, walletFactory, controllerUtils) {
$scope.title = 'Import a backup';
$scope.getFile = function() {
var reader = new FileReader();
// If we use onloadend, we need to check the readyState.
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
var obj = JSON.parse(evt.target.result);
$rootScope.wallet = walletFactory.fromObj(obj);
controllerUtils.startNetwork($rootScope.wallet);
}
};
reader.readAsBinaryString($scope.file);
};
});