4

I am using ng2-uploader in my angular2 application.

Here is my code:

 options: Object = {
   url: "http://localhost/APP/opsnd/api/index.php/mydkd/configured/?"+JSON.stringify(this.type)
 };

What I did in the above code is that I appended a parameter which is changed dynamically and sent to the server along with the file.

Html:

input type="file" ngFileSelect  [options]="options" (onUpload)="handleUpload($event)" (beforeUpload)="beforeUpload($event)">

The problem is, when I select a file, it is automatically loaded to the server using the default [option] url. So even if the parameters in the url changes, the default url is what is sent to the serve. How can I dynamically change the [options] so that it listens to changes in my component?

Chrillewoodz
  • 27,055
  • 21
  • 92
  • 175
valentine
  • 457
  • 8
  • 17

1 Answers1

4

there is a setOptions() method where you can update your new URL like below,

this.uploader.setOptions({ url: newUrl });

Hope this helps!

TheParam
  • 10,113
  • 4
  • 40
  • 51
miholzi
  • 922
  • 1
  • 14
  • 36