zefoy / ngx-dropzone-wrapper

Angular wrapper library for Dropzone
MIT License
174 stars 51 forks source link

Override uploadFiles() Prototype when using ngx-dropzone-wrapper #118

Open ktwbc opened 6 years ago

ktwbc commented 6 years ago

Is there a best practices or acceptable way to override a function within dropzone when using the wrapper? I'm attempting to use my own uploadFiles() function to do something different than xhr.

With normal JavaScript, I would change the class like this:

Dropzone.prototype.uploadFiles = function (files) {
  for (var j = 0; j < files.length; j++) {
    var file = files[j];
    myCustomSendFunction(file);
  }
};

But this only works if I'm in control of the Dropzone object from the beginning. With the wrapper class in Angular 6, I can't really find the appropriate place to do something like this. I can get to the object in my ngOnInit() with something like this.drpzone.directiveRef.dropzone() but don't really know how to attach anything custom that would work there.

Any suggestions?

sconix commented 6 years ago

I must say that I do not know, never needed to do such thing in Angular. Maybe ask around in Angular support forums since I don't think that is tide to this library in anyway, more of an generic Angular question.

My guess is that it should not be no different, Angular is javascript after all and the dropzone library is loaded the same way as in javascript apps.