return method JS

1

I have the following method:

 $scope.upload = function (files) {
    if (files && files.length) {
        for (var i = 0; i < files.length; i++) {
            var file = files[i];
            if (!file.$error) {
                Upload.upload({
                    url: '/CreCpa/getExtrato',
                    data: {
                       // tela: "tarefa",
                       //registro: $scope.registro2.t0060_id_tarefa,
                        file: file
                    }
                }).then(function (resp) {
                    //$timeout(function () {
                    //    $scope.log = 'arquivo: ' +
                    //    resp.config.data.file.name +
                    //    ', resultado: ' + JSON.stringify(resp.data) +
                    //    '\n' + $scope.log;
                    //});
                }, null, function (evt) {
                    //var progressPercentage = parseInt(100.0 *
                    //        evt.loaded / evt.total);
                    //$scope.log = 'progress: ' + progressPercentage +
                    //    '% ' + evt.config.data.file.name + '\n' +
                    //  $scope.log;                      
                })
            }
        }
    }
};

This method works normally, and returns a json, my doubt is how to get the json data and put it in a variable, since I do not know what "variable" this json is returned in.

I tried to put a .success;

$scope.upload = function (files) {
    if (files && files.length) {
        for (var i = 0; i < files.length; i++) {
            var file = files[i];
            if (!file.$error) {
                Upload.upload({
                    url: '/CreCpa/getExtrato',
                    data: {
                       // tela: "tarefa",
                       //registro: $scope.registro2.t0060_id_tarefa,
                        file: file
                    }
                }).then(function (resp) {
                    //$timeout(function () {
                    //    $scope.log = 'arquivo: ' +
                    //    resp.config.data.file.name +
                    //    ', resultado: ' + JSON.stringify(resp.data) +
                    //    '\n' + $scope.log;
                    //});
                }, null, function (evt) {
                    //var progressPercentage = parseInt(100.0 *
                    //        evt.loaded / evt.total);
                    //$scope.log = 'progress: ' + progressPercentage +
                    //    '% ' + evt.config.data.file.name + '\n' +
                    //  $scope.log;                      
                }).success(function (data) {
                     $scope.transactions = data;

                });
            }
        }
    }
};

but gave this error:

thisisthereturn:

    
asked by anonymous 08.11.2016 / 21:57

0 answers