我使用blueimp文件上传插件的angularjs版本。(WebSite)
如果我第一次上传文件,但第二次插件上传文件和第一次...
我看到上传后$ scope.queue没有重置。有一个明确的功能,但我不知道如何使用它。
有我的代码:
candidats.controller('cvUploadController', function($scope, $rootScope, $http, $modal, $window, $location, toaster, $timeout) {
var indexFile = 0;
$scope.options = {
url: '/api/CvAPI/',
autoUpload: false,
dropZone: $('fileupload'),
done: function(e, data) {
$scope.filename = data.result.result;
$scope.array = $scope.candidat.NiveauEtude.Libelle.split('+');
$http.put("/api/CvAPI?fileName=" + $scope.filename + "&path=" + $scope.array[0] + "%2B" + $scope.array[1] + "&CandidatID=" + $scope.candidat.ID + "&NomCv=" + $scope.fichiers[indexFile].nom + "&CvID=0" + "&LangueID=" + $scope.fichiers[indexFile].langueID)
.success(function() {
$scope.getCvs();
});
indexFile++;
if (indexFile == $scope.fichiers.length) {
indexFile = 0;
}
}
};
$scope.$on('fileuploadstop', function(e, data) {
$scope.getCvs();
$scope.fichiers = [];
$scope.queue = [];
});
$scope.$on('fileuploadchange', function(e, data) {
$.each(data.files, function(index, file) {
var fichier = {
nom: file.name.replace(/\.[^\.]*$/, ''),
langueID: 1
}
$scope.fichiers[index] = fichier;
if (index == data.files.length - 1) {
$('#CvModal').modal();
}
});
})
});
这是HTML:
<div class="row" ng-controller="cvUploadController">
<form id="fileupload" method="POST" enctype="multipart/form-data" file-upload="options" ng-class="{'fileupload-processing': processing() || loadingFiles}">
<div class="col-lg-7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button" ng-class="{disabled: disabled}">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="files[]" multiple ng-disabled="disabled">
</span>
<!-- The global file processing state -->
<span class="fileupload-process"></span>
</div>
<!-- The global progress state -->
<div class="col-lg-5 fade" ng-class="{in: active()}">
<!-- The global progress bar -->
<div class="progress progress-striped active" file-upload-progress="progress()">
<div class="progress-bar progress-bar-success" ng-style="{width: num + '%'}"></div>
</div>
<!-- The extended global progress state -->
<div class="progress-extended"></div>
</div>
<div class="modal fade" id="CvModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="padding-top:10px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Détails Cv</h4>
</div>
<div class="modal-body">
<div ng-repeat="data in fichiers">
<label>Nom Cv</label>
<input class="form-control" ng-model="fichiers[$index].nom" />
<br />
<select class="form-control" ng-model="fichiers[$index].langueID" ng-options="langue.ID as langue.Libelle for langue in languesCv"></select>
<br />
</div>
<button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="cancel()">Annuler</button>
<a class="btn btn-success" data-dismiss="modal" ng-click="submit()">Valider</a>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</form>
</div>
提前致谢!