mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
20 lines
575 B
JavaScript
20 lines
575 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
|
|
}
|
|
])
|
|
}
|
|
])
|