如果使用ngCsv

时间:2016-07-18 15:18:58

标签: javascript angularjs csv

我正在使用ngCsv。我有以下问题。 csv文件的内容是承诺的结果。一切都好,但是当出现错误时,csv下载任何方式。我需要,如果存在错误,csv文件不会开始下载。

我的代码



$scope.getCsv = function()
    {
        var body = mlService.getMatrixFromCsv($scope.p.fileContent, $scope.features, $scope.p.head);
        if(body[0].length != $scope.features.length || body[0][1] == undefined)
        {
            $scope.page_error = "csv file It does not correspond with model";
            $timeout(function () {
                $scope.page_error = "";
            }, 10000);
        }
        else
        {
            $scope.csvheader = $scope.features;
            $scope.csvheader.push("predict");
            $scope.csvContent = $http.post(mlService.getMlMultitenancyOrigin()+ '/python/predict', {"model":$scope.params[2], "value": body}).then(function(result){
                var data = mlService.buildMatrixCsvFromResponse(body, $scope.features, JSON.parse(result.data));
                return data;
            });
            return $scope.csvContent;
        }
    }

<button class="btn btn-primary r" type="button" ng-csv="getCsv()" filename="predcit.csv" csv-header="csvheader"><i class="fa fa-rocket" aria-hidden="true"></i>&nbsp;Predict</button>
&#13;
&#13;
&#13;

0 个答案:

没有答案