导入文件并在弹出窗口关闭时提交AngularJS
我想提交一个文件,我输入了一次,我点击了系统窗口上的文件上传确定,但我不知道该怎么做......这就是我'已经这样做的远:导入文件并在弹出窗口关闭时提交AngularJS
<input type="file" id="file-input" style="display:none" /> <button class="btn pull-right" ng-click="submitCashierFile()">Import</button> 
JS:
$scope.submitCashierFile = function() {      angular.element('#file-input').trigger('click'); 
// I should have something like this next i guess? 
$scope.cashierfile.upload = Upload.upload({ 
       url: config.baseAddress + 'test/uploadCashierExcel', 
       data: { file: $scope.cashierfile } 
      }); 
      $scope.cashierfile.upload.then(function (response) { 
       $timeout(function() { 
        $scope.cashierfile.result = response.data; 
        toastService.success('You have added .xlsx'); 
       }); 
      }, function (response) { 
       toastService.error(response); 
      }); 
    }; 
所以我通过靶向点击,打开模式选择文件,对我来说,问题是如何提交上单击该模式的确定。有什么建议么?
回答:
你的问题对我来说不是很清楚,但我会根据我的理解给它一个基础。
您应该映射控件的onchange事件。这会在选择要上传的文件后立即激活。 然后你应该做文件的实际上传。
当我需要完成这项任务时,我放弃使用Angular并转而使用HTML5文件上传机制。那一个正如你所描述的那样工作...
以上是 导入文件并在弹出窗口关闭时提交AngularJS 的全部内容, 来源链接: utcz.com/qa/265659.html







