phusick
11/22/2017 - 8:35 AM

AngularJS [$rootScope:inprog] inprogress error

angular.module('main', []).service('scopeService', function() {
  return {
    safeApply: function ($scope, fn) {
      var phase = $scope.$root.$$phase;
      if (phase == '$apply' || phase == '$digest') {
        if (fn && typeof fn === 'function') {
          fn();
        }
      } else {
          $scope.$apply(fn);
        }
      },
    };
});