I have a small directive where the is a button, and a hidden input file.
I would like to create a click handler when the button is clicked, so I would click the input file that is hidden.
My directive:
app.directive('fileUpload', function($timeout) {
return {
restrict: 'E',
templateUrl: "templates/partials/file-upload.html",
controller: ['$scope', function ($scope) {
$scope.fileInput = "";
$scope.clickedImageUpload = function () {
console.log($scope.fileInput);
$scope.fileInput.click();
};
}],
link: function(scope, element, attrs) {
console.log(element);
var fileInput = angular.element().find('.invisibleFileInput').html;
scope.fileInput = element[0].getElementsByClassName('invisibleFileInput');
console.log(scope.fileInput);
}
};
});