I want to trigger/open a file input coming from another page in Ionic 4.
In page 1 I have a button to go to page 2 with params, in page two I get the param so I want to automatically trigger the <input file> dialog that I have in page two.
page-two.ts
ionViewWillEnter() {
document.getElementById('file').click(); // Tried with this one 1st
this.fileInput.nativeElement.click(); // And also this with @ViewChild
}
What does this mean? Are you using navparams? Your ionViewWillEnter code looks wrong to me, but I don’t know what you are trying to do, so I can’t suggest how to correct it.
I’m using navparams, but that doesn’t matter as I can’t achieve to open the file input programmatically .
ionViewDidLoad() {
if (navParams.data.test == true) { // works
// Reach here but input file doesnt show up
document.getElementById('file').click(); // doesn't work
}
}
I’m using Ionic 4 version, it’s ionic2 core concept.
I transition with this.navCtrl.push('Page2', {test: true}); This works, it’s the input that doesn’t, forget about the transition between pages as I can open the file input in the same page programmatically