1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00
OpenSTF/res/app/components/stf/common-ui/safe-apply/index.js
2016-01-19 23:08:33 +09:00

20 lines
572 B
JavaScript

module.exports = angular.module('stf.safe-apply', [])
.config([
'$provide', function($provide) {
return $provide.decorator('$rootScope', [
'$delegate', function($delegate) {
$delegate.safeApply = function(fn) {
var phase = $delegate.$$phase
if (phase === '$apply' || phase === '$digest') {
if (fn && typeof fn === 'function') {
fn()
}
} else {
$delegate.$apply(fn)
}
}
return $delegate
}
])
}
])