Reputation: 457
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?
Upvotes: 4
Views: 1259
Reputation: 1004
there is a setOptions()
method where you can update your new URL like below,
this.uploader.setOptions({ url: newUrl });
Hope this helps!
Upvotes: 5