Skip to content

Commit 4556cdb

Browse files
author
Roberto Lucha
committed
Expose internal data.submit promise as angular promise.
1 parent d7db3ba commit 4556cdb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

js/jquery.fileupload-angular.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@
201201
// The FileUploadController initializes the fileupload widget and
202202
// provides scope methods to control the File Upload functionality:
203203
.controller('FileUploadController', [
204-
'$scope', '$element', '$attrs', '$window', 'fileUpload',
205-
function ($scope, $element, $attrs, $window, fileUpload) {
204+
'$scope', '$element', '$attrs', '$window', 'fileUpload','$q',
205+
function ($scope, $element, $attrs, $window, fileUpload, $q) {
206206
var uploadMethods = {
207207
progress: function () {
208208
return $element.fileupload('progress');
@@ -264,19 +264,21 @@
264264
$scope.applyOnQueue = function (method) {
265265
var list = this.queue.slice(0),
266266
i,
267-
file;
267+
file,
268+
promises = [];
268269
for (i = 0; i < list.length; i += 1) {
269270
file = list[i];
270271
if (file[method]) {
271-
file[method]();
272+
promises.push(file[method]());
272273
}
273274
}
275+
return $q.all(promises);
274276
};
275277
$scope.submit = function () {
276-
this.applyOnQueue('$submit');
278+
return this.applyOnQueue('$submit');
277279
};
278280
$scope.cancel = function () {
279-
this.applyOnQueue('$cancel');
281+
return this.applyOnQueue('$cancel');
280282
};
281283
// Add upload methods to the scope:
282284
angular.extend($scope, uploadMethods);

0 commit comments

Comments
 (0)