0
我使用ng2FileUpload创建拖N - 下降上传,但我也希望允许用户点击下拉区域打开文件对话框。如何打开从角输入类型=“文件”对话框 - ng2FileUpload
考虑到我有这个输入:
<input type="file" ng2FileSelect [uploader]="uploader" style="display: none" />
我如何可以显示从角4打字稿代码文件对话框?
我使用ng2FileUpload创建拖N - 下降上传,但我也希望允许用户点击下拉区域打开文件对话框。如何打开从角输入类型=“文件”对话框 - ng2FileUpload
考虑到我有这个输入:
<input type="file" ng2FileSelect [uploader]="uploader" style="display: none" />
我如何可以显示从角4打字稿代码文件对话框?
我已经能够做到这一点是这样的:
模板:
<input type="file" ng2FileSelect [uploader]="uploader" style="display: none" #fileInput />
角度成分:
@ViewChild('fileInput') fileInput:ElementRef;
public openFileDialog():void {
let event = new MouseEvent('click', {bubbles: false});
this.fileInput.nativeElement.dispatchEvent(event);
}
一个简单的this.fileInput.nativeElement.click()也适用 –