Skip to content

Commit 962c06a

Browse files
Arthur AgombartArthur Agombart
authored andcommitted
fix(src): $q instead of Promise
1 parent 05ef557 commit 962c06a

File tree

2 files changed

+8
-94
lines changed

2 files changed

+8
-94
lines changed

dist/angularjs-input-file.js

Lines changed: 1 addition & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/input-file.component.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class InputFileComponent {
22
/** @ngInject */
3-
constructor($timeout, $element, $attrs) {
3+
constructor($q, $timeout, $element, $attrs) {
4+
this.$q = $q;
45
this.$timeout = $timeout;
56
this.$element = $element;
67
this.$attrs = $attrs;
@@ -29,7 +30,7 @@ class InputFileComponent {
2930
onInputChange(event) {
3031
const inputFiles = event.target.files;
3132
const files = [];
32-
const fileLoaded = [...inputFiles].map(inputFile => new Promise((resolve, reject) => {
33+
const fileLoaded = [...inputFiles].map(inputFile => this.$q((resolve, reject) => {
3334
if (!this.fileFormat) {
3435
resolve(inputFile);
3536
return;
@@ -71,12 +72,10 @@ class InputFileComponent {
7172
}
7273
}));
7374

74-
return Promise.all(fileLoaded).then(response => {
75-
if (this.filesLoaded) {
76-
this.filesLoaded({
77-
files: response
78-
});
79-
}
75+
return this.$q.all(fileLoaded).then(response => {
76+
this.filesLoaded({
77+
files: response
78+
});
8079
});
8180
}
8281
}

0 commit comments

Comments
 (0)