Comments (8)
Hi
1, 3. You can disable the submit button until will not be filled required fields.
2. You can get a response as shown in the code below.
uploader.bind('success', function (event, xhr, item, response) {}); // response
uploader.bind('error', function (event, xhr, item, response) {}); // response
https://github.com/nervgh/angular-file-upload#events
4. Please, update your module to last version
from angular-file-upload.
ok i've updated the module to 0.3!
- i know that i can disable it, but i'm testing server-side validation..
- i added the response like you said, but it triggers success twice (the console.log is outputed twice)
new code:
// successful upload
uploader.bind('success', function (event, xhr, item, response) {
console.log('success')
uploader.clearQueue();
successCallback(response);
});
// unsuccessful upload
uploader.bind('error', function (event, xhr, item, response) {
errorCallback(response);
});
workflow:
- unsuccessful upload = error
- then successful upload = success but 2x
from angular-file-upload.
- then successful upload = success but 2x
You have two event listeners, probably.
You can get the number of listeners so:
uploader.bind('success', function (event, xhr, item, response) {
var listeners = this.scope.$$listeners[this._timestamp+':success'];
console.info('listeners.length', listeners.length); // 1 - if there is one listener
});
from angular-file-upload.
hmm that's strange, normally i have 1 listener, and just when I do what causes the problem I got 2!
do you know how I can solve this?
from angular-file-upload.
i did this dirty hack and it works now:
var listeners = this.scope.$$listeners[this._timestamp+':success'];
if(listeners.length > 1) {
listeners.pop();
}
from angular-file-upload.
do you know how I can solve this?
Add one event listener =)
You can test this so
console.log('new listener', uploader.scope.$$listeners[uploader._timestamp+':success'].length); // 1
uploader.bind('success', function (event, xhr, item, response) {
from angular-file-upload.
It's better to bind to events just at initialization.
Startup:
// successful upload
uploader.bind('success', function (event, xhr, item) {
console.log("success")
uploader.clearQueue();
var response = angular.fromJson(xhr.response);
successCallback(response);
});
// unsuccessful upload
uploader.bind('error', function (event, xhr, item) {
var response = angular.fromJson(xhr.response);
errorCallback(response);
});
Submit:
if(uploader.queue.length) {
var firstItem = uploader.queue[0];
uploader.uploadItem(firstItem);
}
from angular-file-upload.
try to check your $routeProvider, may be your routing execute your controller twice
from angular-file-upload.
Related Issues (20)
- angular is not defined HOT 1
- Unable to upload file from Angular 7/8 and backend Spring security project HOT 2
- Callback when no file was valid HOT 3
- timeout HOT 1
- Calling a upload function on button click instead of image upload. HOT 1
- Rename file upload "choose file"
- onAfterAddingFile callback not firing without code change HOT 1
- Rename file according to input name HOT 2
- Bug in IE setting xhr.timeout before xhr.open() in version 2.6.0 HOT 4
- ngf-thumbnail is breaking image orientation HOT 2
- Question: clearing the input.value property to circumvent a bug in chrome
- Drag and Drop not working in Chrome occasionally HOT 2
- "Unsupported Media Type", message: "Content type 'application/octet-stream' not supported"
- Get real path File before upload
- angular1 single item does not add formdata HOT 1
- When I send a file single file use sample code, ,i got a page reload
- Sabuj gazi
- Adding an image captured via camera HOT 1
- How do you post the file data to ASP.Net HOT 1
- How to Costume Header HTTP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-file-upload.