为什么ng-file-upload的进度功能刚被触发两次?

时间:2017-05-02 14:21:48

标签: ng-file-upload

我想使用progress函数来显示上传的进度。但是,进度函数在开始时只调用了两次。因此,进度的值始终为0.

<input name="file" data-ngf-select type="file" style="display: none" ng-model="uploadCtrl.file"
       ng-show="false" ngf-max-size="20MB" ngf-change="uploadCtrl.invalidFile()"
       accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">

Upload.upload(
                {
                    url: PathUtils.qualifiedAPIPath(url),
                    headers: {
                        'Access-Control-Allow-Origin': '*'
                    },
                    data: param,
                    method: 'post',
                    arrayKey: ''
                }).then(success, function (error) {
                conn.errorHandler(error.data, error.status)
            }, progress);

function progress() {
            if (document.getElementById("mask") != null) {
                document.getElementById("mask").style.display = 'block';
                $http({
                          'url': PathUtils.qualifiedAPIPath("progress"),
                          'method': "get"
                      }).success(function (res) {
                    document.getElementById("mask-progress").innerHTML = res + '%';
                }).error(conn.errorHandler);
            }
        }

0 个答案:

没有答案