I'm using AngularJS (1.2.28) and ng-file-upload directive (7.0.17). On the backend there's a WCF service hosted in IIS 7.
I'm trying to display a progress bar per uploaded file and here's my code:
uploadsController
controller('uploadsController', ['$scope', 'Upload', function($scope, Upload) {
$scope.upload = [];
$scope.select = function(files) {
for(var i = 0; i < $scope.files.length; i++) {
files[i].progress = 0;
}
}
$scope.submit = function() {
for(var i = 0; i < $scope.files.length; i++) {
var $file = $scope.files[i];
(function(index) {
$scope.upload[index] = Upload.upload({
url: "/documents-manager/UploadsService.svc/upload",
method: "POST",
file: $file
}).progress(function(evt) {
$file.progress = parseInt(100.0 * evt.loaded / evt.total);
});
})(i);
}
}
}
corresponding markup
<div ngf-select="select($files)" ng-model="files" ngf-multiple="true">search</div>
<tbody>
<tr ng-repeat="file in files">
<td>
<div>{{ file.name }}</div>
<div class="progress">
<span class="meter" style="width:{{ file.progress }}%;"</span>
</div>
</td>
</tr>
</tbody>
the problem
The progress is getting displayed only for the last file in the queue. What is wrong?