Angular Error: $digest already in progress

Due to the existence of asynchrony (delay), when the callback function starts to be executed, the dirty value detection in angularJS' own controller has ended, and the data change caused by the callback function cannot be detected. The changed data is not refreshed to the interface

Solution

function apply(scope) {
  if (!scope.$$phase && !scope.$root.$$phase) {
    scope.$apply();
    console.log("Scope Apply Done !!");
  } 
  else {
    console.log("Scheduling Apply after 200ms digest cycle already in progress");
    setTimeout(function() {
        apply(scope)
    }, 200);
  }
}

Just call apply($scope)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326641410&siteId=291194637