I am new on angular and stuck while using one lib name ng2-file-upload.
I want to pass the static value from input value to onBeforeUploadItem function.
So here is my code.
`<div class="main" *ngFor="let att of attachment">
{{att.name}}
<div ng2FileDrop [uploader]="uploader"
(click)="fileInput2.click()">
<span class="drop-text">Drop your
document here, or <span class="browser-text">browse</span>
</span>
<input type="file" #fileInput2 ng2FileSelect
[uploader]="uploader" style="display: none" />
</div>
</div>`
Here I have 5 different attachments and parse them on html DOM and If I drop any file on any of the uploader then I also want to pass that attachment name along with file data.
ts file code.
`ngOnInit(): void {
this.uploader = new FileUploader({
url: url,
autoUpload: true,
authToken: `Bearer ${this.token}`,
headers: [
{ name: "x-requested-with", value: "XMLHttpRequest" },
],
maxFileSize: 2000,
});
this.uploader.onBeforeUploadItem = (item: FileItem) => {
console.log("3", item);
this.uploader.options.additionalParameter = {
name: name, // here I want to pass that attachment name
};
` };
}
Any feedback will be helpful for me.