I have this code in Html file .
demo.ts
import {
Component,
No need to write code in controller
<input #fileInput type="file" />
<button type="button" (click)="fileInput.click()">trigger</button>
Pass the fileInput
reference to triggerFile()
and do the fileInput.click()
there instead:
<input #fileInput type="file" />
<button type="button" (click)="triggerFile(fileInput)">trigger</button>
triggerFile(fileInput:Element) {
// do something
fileInput.click();
}