<input type="file" ng-model="myobj.file" ng-file-select="onFileSelect_filter($files)" id="fileButton" >
<button type="button" ng-click="start_Filter();" >Upload</button>
我的 onFileSelect_filter() 函数是这样的,
$scope.onFileSelect_filter = function($files){
....
};
我至少要在 Internet Explorer 中单击上传 按钮后清除文件名。
这个输入框不在表单里面 提前致谢...!!!
最佳答案
不幸的是,在这种情况下,将绑定(bind)的 $scope
变量等同于空字符串或 null 将不起作用。
虽然您可以通过下面提到的方法之一来实现它。
方法一:
您必须按字面意思替换 DOM 上的 html 单击(在您的情况下为上传)并将其恢复为上传前的状态。像这样..
$scope.start_Filter = function(){
// This is in the upload function post all your logic
$("#fileButton").replaceWith("<input type='file' ng-model='myobj.file' ng-file-select='onFileSelect_filter($files)' id='fileButton' >").html();
};
注意:对于 replaceWith
函数中的所有 HTML 属性值,您必须使用单引号而不是双引号
方法二:
或者,您可以使用 JQuery 轻松清除文件名。像这样..
$scope.start_Filter = function(){
// This is in the upload function post all your logic
$("#fileButton").val('');
};
其中一个应该可以工作。请尝试一下,如果您遇到任何问题,请告诉我。
关于javascript - 如何使用 Angularjs 在 Internet Explorer 中上传文件后清除文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23651741/