I am using angular js fileModel directive to upload file, which is as below
angular.module('MyProject').directive('fileModel', ['$parse', function ($parse) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var model = $parse(attrs.fileModel);
var modelSetter = model.assign;
element.bind('change', function(){
scope.$apply(function(){
modelSetter(scope, element[0].files[0]);
});
});
}
};
}]);
And I am using the same in html as below,
<input type='file' class="imgInp" file-model="tenantLogoFile"/>
If I select one file then Its fine for me to capture the file chosen by user by using $watch on "tenantLogoFile". But if I am supposed to upload same file (Without refreshing page) immediately again, $watch does not get fired and ultimately I am unable upload the file.
I tried setting $scope.tenantLogoFile = null after first time successful upload, but no use, Can anyone help me please?