I am using HTML5's file selector with AngularJS (I know the input with file type is not supported in Angularjs and I hacked a bit.), the file name will not get cleared for the 2nd upload. Any idea why??
<div ng-app="app">
<div ng-controller="Ctrl">
<input ng-model="myFile" onchange="angular.element(this).scope().onchange(this.files)" type="file" />
</div>
</div>
var app = angular.module("app", []);
function Ctrl($scope) {
$scope.onchange = function (files) {
var file = files[0];
var reader = new FileReader();
reader.onload = function (e) {
//doing some stuff here
console.log(e)
//finally clear the file for new selection
$scope.myFile = null; // <------- doesn't clear after the 2nd file upload
$scope.$apply();
};
reader.readAsText(file);
};
}
How to reproduce?
Go to the jsfiddle and upload the same file twice.
I am not processing today somehow. Any help is highly appreciated!