I've made a Angular directive to warp the a file upload input.
directive('ngFile', function () {
return {
link: function (scope, element, attrs) {
var button = element.find('button[data-fileInputButton]');
var inputElement = element.find('input[type="file"]');
var updateModel = function (evt) {
scope.$apply(function () {
scope.files = evt.target.files;
if (scope.startUpload) {
scope.startUpload();
}
evtl.target.files = [];
});
}
inputElement.bind('change', updateModel);
button.click(function () {
var input = element.find('input[type="file"]');
input.click();
});
}
}
});
When I click and select a file, everything is OK. However, when I select the file again, the event is not fired. It is only fired when I select another file. Why is this happening?