Typescript doesn't compile e.currentTarget.files
I have read with Jquery input files
<INPUT TYPE=FILE id="file" NAME="upfile" multiple>
With this code
$('#inputFile').on('change', 'body', (e) => {
var files: any = e.currentTarget.files; });
But typescript doesn't know that e.currentTarget has poperty files in this case. And give me a compile error.
How can I solve this problem?
Thank you in advance
+3
source to share
3 answers
Similar to @ michael-tranchida, but I think a little cleaner:
export class Page {
public fileToUpload:File = null;
constructor(public fileInput: JQuery, public fileDetails: JQuery) {
$(fileInput).on('change', (e) => {
this.fileToUpload = <File>$(e.target).prop('files')[0];
$(fileDetails).html(this.fileToUpload.name); // intellisense on fileToUpload
});
}
}
0
source to share