触摸输入文件在页面更改后单击Ionic 4

Nov*_*ovo 11 html javascript ionic-framework angular

我想触发/打开来自Ionic 4中另一页的文件输入.

在第1页中,我有一个按钮可以转到模态,在页面模态中我想自动触发<input file>对话框

零件

ionViewWillEnter() {
    document.getElementById('file').click(); // Tried with this one 1st, this only works in Internet Explorer / Edge
    this.fileInput.nativeElement.click();    // And also this with @ViewChild
}
Run Code Online (Sandbox Code Playgroud)

HTML

<input type="file" name="file" #file id="file" (change)="fileChange($event)" required>
Run Code Online (Sandbox Code Playgroud)

Nov*_*ovo 1

我解决了这个问题,在 page1 中插入一个隐藏的输入文件,当用户尝试转到 page2 时,我触发文件输入。

当用户完成选择文件后,我将文件事件更改发送到第 2 页并管理第 2 页中的所有逻辑。