AngularJS : Prevent error $digest already in progress when calling $scope.$apply()

前端 未结 28 3126
伪装坚强ぢ
伪装坚强ぢ 2020-11-21 22:31

I\'m finding that I need to update my page to my scope manually more and more since building an application in angular.

The only way I know of to do this is to call

28条回答
  •  深忆病人
    2020-11-21 23:10

    similar to answers above but this has worked faithfully for me... in a service add:

        //sometimes you need to refresh scope, use this to prevent conflict
        this.applyAsNeeded = function (scope) {
            if (!scope.$$phase) {
                scope.$apply();
            }
        };
    

提交回复
热议问题