angularjs - JQuery File input element inconsistently fires in Chrome when wrapped in $timeout -


so, have directive handling file uploads, (wraps around angular-file-upload), , in instances directive wraps anchor tag. anchor tag's click event results in $apply being run when directive runs following code, .fileuploadinput element <input type="file" />:

fileuploadclick = (event: any) => {   this.element.find('.fileuploadinput').click(); }; 

to solve problem wrapped in $timeout:

fileuploadclick = (event: any) => {   this.$timeout(() => {     this.element.find('.fileuploadinput').click();   }); }; 

in chrome 43 (not ff/safari), file picker requires multiple click events before opening os picker. can see function call inside timeout run each time, intermittently os picker open. removing $timeout cause picker open every time, cause $apply in progress error.

does 1 have idea cause adding timeout cause behavior in chrome? alternatively, there way stop existing $apply or way wait outside of $timeout? $interval causes same problem.

thanks,

matt


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -