PrimeNG手动调用FileUpload [英] PrimeNG manually invoke FileUpload
本文介绍了PrimeNG手动调用FileUpload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想先选择文件,然后再通过另一个按钮而不是组件自己的Upload
按钮开始上传这些文件.
I want to select the files first and then to start upload those files by an another button instead of component's own Upload
button.
我该怎么做?
示例代码,我尝试过:
<button pButton type="button" label="Start Upload"
(click)="startUpload()"></button>
<p-fileUpload #fileInput name="fileIcon"
url="rest/batch/file/multimedia/"></p-fileUpload>
@ViewChild('fileInput') fileInput:ElementRef;
constructor( private renderer: Renderer ) { }
startUpload(){
// this.fileInput.upload(); -> doesn't compile, undefined
// this.fileInput.nativeElement.upload(); -> this.fileInput.nativeElement is undefined
?????????????????
}
推荐答案
适用于我的示例代码
import {FileUpload} from 'primeng/primeng';
@Component({
...
})
export class AppComponent {
@ViewChild('fileInput') fileInput: FileUpload;
startUpload(){
this.fileInput.upload();
}
}
Plunker Example
这篇关于PrimeNG手动调用FileUpload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文