ui-mask
ui-mask copied to clipboard
blurHandler
Added condition to check $$phase on $rootScope.
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
I have the same issue ($digest already in progress). Any ideas how to handle this without checking the $$phase property?
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.
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.