How To Trigger Event Click At Input Type="file" By Function In Angular 2?
I have this code in Html file . demo.ts import { Component, Inject, OnInit, ElementRef, Renderer, ViewQuery } from '@angular/co
Solution 1:
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();
}
Solution 2:
No need to write code in controller
<input #fileInputtype="file" /><buttontype="button" (click)="fileInput.click()">trigger</button>
Post a Comment for "How To Trigger Event Click At Input Type="file" By Function In Angular 2?"