Using Angular v2.4.8 and PrimeNg v1.1.4
I have a page with two components:
- Dropzone, for uploading files
- p-datatable to show the uploaded files
I configured Dropzone to send 5 files at a time and when it is finished with 5 files the event onDropZoneSendingMultiple
is raised. When all files are uploaded onDropZoneQueueComplete
is raised.
In both listeners I want to refresh the datatable which is in the second component. This is not working. I need to refresh the page to see the new files.
My HTML of the main page:
<div class="row" id="dropzoneContainer">
<dropzone class="dropzone" #dz [config]="dropZoneConfig"
(error)="onDropZoneUploadError($event)"
(sendingmultiple)="onDropZoneSendingMultiple($event)"
(queuecomplete)="onDropZoneQueueComplete($event, dz);"
(maxfilesreached)="onDropZoneMaxfilesReached($event)"
(maxfilesexceeded)="onDropZoneMaxfilesExceeded"></dropzone>
</div>
<div class="row">
<div class="col-md-12">
<FilesList></FilesList>
</div>
</div>
The Dropzone
-component shows the dropzone. The FilesList
shows the datatable.
Part of the HTML:
<p-dataTable [hidden]="loading" [value]="files" selectionMode="single" (onRowSelect)="details($event)">
In my main ts-file I have:
@ViewChild(FilesListComponent)
public filesListComponent: FilesListComponent;
private reloadFileList() {
this.filesListComponent.reload();
}
In my filelist ts I have
public files: File[];
public reload() {
this.getFiles();
}
public getFiles() {
this.fileService.getAll()
.then(
data => {
this.files = data;
});
}
getFiles
is also called at page load.
When I add console.log()
statements I can see getFiles()
is called and this.files
is updated, but the table doesn't refresh.