How to reset selected file with input tag file type in Angular 2?

前端 未结 13 1881
北恋
北恋 2020-12-12 14:56

This is how my input tag looks like:


相关标签:
13条回答
  • 2020-12-12 15:33

    you may use template reference variable and send to a method

    html

    <input #variable type="file" placeholder="File Name" name="filename" (change)="onChange($event, variable);">
    

    component

    onChange(event: any, element): void {
        // codes
        element.value = '';
      }
    
    0 讨论(0)
提交回复
热议问题