Input file trigger twice click when show the action sheet

Hi I’m Cristian,
I started using Ionic recently, is very powerful and easy to use.

I’m trying to use a button with type file for uploading an image but I have a problem with the action sheet on IOS.
This is part of the view:

<input type="file"  id="upload-file" onchange="angular.element(this).scope().fileNameChanged()" />
    <div class="row">
    	 <button class="button" ng-click="uploadPhoto()" style="width:100%"> +
    	   <i class="icon ion-camera"></i>
   		</button>
    </div>

and this is part of the controller:

$scope.uploadPhoto = function(){
	$('#upload-file').click()
}

$scope.fileNameChanged = function() {
var image = $('#upload-file')[0].files[0];
....some code
}

When I click on the button, I trigger an event ‘click’ on hidden file input.
After the click I see the action sheet, there are two possibilities: take a photo or choose from library.
When returning to the view of app, the next click on the screen show me the action sheet again. How it’s possible?
Can you help me?

Cristian

Hi there,

I have encountered the same issue.

My input field is directly triggered by tapping on it. The action sheet dialog is always triggered twice. The first dialog appears directly - the second one after doing the next click (arbitrary element).

Seems to be some event handling issue. I tried setting the disable-tap attribute, but that didn’t make any difference.

Greetings,
Chris

1 Like

please refer this link url