Hy I have a div that simulates an input file button. To achieve this I did
angular.element('#fileInput').trigger('click');
but this generated an Apply already in progress error, googling around I found that this could easily be avoided putting the code inside a timeout.
timeOut = $timeout(function(){
angular.element('#fileInput').trigger('click');
});
And as an effect that really solved the problem, but $timeout generates an infinite loop opening infinite file dialogs if my pop-up block is disabled. In the AngularJS docs you can clearly read that $timeout is a wrapper of setTimeout wich should only generate one call to the callback function, so why is it generating an infinite loop? However, trying to solve the situtation I decided to kill the timer after the first call, but I couldn't manage,
timeOut = $timeout(function(){
angular.element('#fileInput').trigger('click');
});
timeOut.then( function( ){$timeout.cancel(timeOut);
}
);
I'm getting quite stuck in this situation... I'm I just missing something obvious things? Someone has any idea's? thank's
$timeoutis the source of the problem (unless you're using a version of Angular that has a bug with it). I was suggesting that it's possible the code/function that contains this trigger is being called in recursion, causing the problem. I can't reproduce with a simple jsFiddle (jsfiddle.net/twp3e6h2), so you're going to need to, otherwise it doesn't make sense