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

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

This is how my input tag looks like:


13条回答
  •  遥遥无期
    2020-12-12 15:08

    I have add this input tag into form tag..

     

    I angular typescript, I have added below lines, get your form id in document forms and make that value as null.

        for(let i=0; i 0){
                 if(document.forms[i][0]['value']){ //document.forms[i][0] = "file_data"
                     document.forms[i][0]['value'] = "";
                  }
          }
        }
    

    Print document.forms in console and you can get idea..

提交回复
热议问题