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
Post a Comment