使用Angular v2.4.8和PrimeNg v1.1.4
我有一个包含两个组件的页面:
我将Dropzone配置为一次发送5个文件,当完成5个文件时,onDropZoneSendingMultiple会引发事件.上传所有文件时onDropZoneQueueComplete.
在两个侦听器中,我想刷新第二个组件中的数据表.这不起作用.我需要刷新页面才能看到新文件.
我的主页HTML:
<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>
Run Code Online (Sandbox Code Playgroud)
该Dropzone-component显示悬浮窗.该FilesList说明了DataTable.部分HTML:
<p-dataTable [hidden]="loading" [value]="files" selectionMode="single" (onRowSelect)="details($event)">
Run Code Online (Sandbox Code Playgroud)
在我的主要ts文件中,我有:
@ViewChild(FilesListComponent)
public filesListComponent: FilesListComponent;
private reloadFileList() {
this.filesListComponent.reload();
}
Run Code Online (Sandbox Code Playgroud)
在我的文件列表中我有
public files: File[];
public reload() {
this.getFiles();
}
public getFiles() {
this.fileService.getAll()
.then(
data => {
this.files = data;
});
}
Run Code Online (Sandbox Code Playgroud)
getFiles在页面加载时也会调用.当我添加console.log()语句时,我可以看到它 …