ui-mask icon indicating copy to clipboard operation
ui-mask copied to clipboard

blurHandler

Open flaviodamaiajr opened this issue 9 years ago • 4 comments

Added condition to check $$phase on $rootScope.

flaviodamaiajr avatar Jul 19 '16 21:07 flaviodamaiajr

Are you running into an issue where a $digest is already in progress?

Also, this is a discouraged use of $$phase and I would rather not incorporate it into the library.

source: https://github.com/angular/angular.js/wiki/Anti-Patterns

lukepfeiffer10 avatar Jul 26 '16 13:07 lukepfeiffer10

I have the same issue ($digest already in progress). Any ideas how to handle this without checking the $$phase property?

shizik avatar Aug 19 '16 15:08 shizik

Generally it is considered safe to do the following:

$timeout(() => {
  $scope.$apply(() => {
     if (!controller.$pristine) {
       controller.$setViewValue('');
     }
  });
}, 0, false);

By using $timeout you are guaranteed to already be in a digest and by passing false as a third parameter $rootScope won't trigger its own digest. The only potential issue is that this will be on another run of the event loop, but given the above code I think it should be fine.

blittle avatar Sep 19 '16 17:09 blittle

This bug is still causing issues. The modern solution is to simply replace all calls to $apply with $applyAsync (introduced in Angular 1.2). I'm deploying my own corrected version of the directive for now.

zamb3zi avatar Oct 19 '17 07:10 zamb3zi