FileUpload: Empty template not working
Describe the bug
FileUpload empty template was working in previous version 17. FileUpload empty template is not working in current version 18-19.
It is also not working in the primeng examples.
Working here: https://v17.primeng.org/fileupload#template
Not working here: https://primeng.org/fileupload#template
Environment
windows 11
Reproducer
No response
Angular version
19.0.4
PrimeNG version
19
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
22.10.0
Browser(s)
Chrome
Steps to reproduce the behavior
No response
Expected behavior
FileUpload empty template should be working with custom content like previous version 17
Will this be back-ported to PrimeNG 18 LTS?
@awdorrin and anyone looking to make the "empty" template work in v18: the fix introduced in v19:
@if ((emptyTemplate || _emptyTemplate) && !hasFiles() && !hasUploadedFiles())
has not been implemented in v18. In v18, the old code remains:
@if (emptyTemplate && _emptyTemplate && !hasFiles() && !hasUploadedFiles())
This means you need to use both approaches for template to make it work. Here's a hackfix which worked for me in v18.0.2:
<p-fileupload ... >
<ng-template pTemplate="empty" #empty>YAY! Empty state works!</ng-template>
</p-fileupload>
Both pTemplate="empty" and #empty are necessary in the template until this issue is resolved in v18.
@PeterSisovsky thanks, i will try that out tomorrow!
Your suggestion works great to show the empty template, thanks again. I had modified my implementation to always show 'Drag and drop files to here to upload' with the following code
<p-fileupload name="accessRequestAttachment"
[multiple]="true"
[customUpload]="true"
(uploadHandler)="onFileUploadClicked($event)"
(onSelect)="onSelectFile($event)"
maxFileSize="1000000"
mode="advanced">
<ng-template #content>
<div>Drag and drop files to here to upload.</div>
</ng-template>
</p-fileupload>
Thanks for the update. Glad it worked for you. Have a nice day!