mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
20 lines
572 B
JavaScript
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
|
|
}
|
|
])
|
|
}
|
|
])
|