search

Home  >  Q&A  >  body text

angular.js - About $apply()


I keep getting errors after using $apply, please answer

天蓬老师天蓬老师2779 days ago540

reply all(1)I'll reply

  • 漂亮男人

    漂亮男人2017-05-15 16:56:08

    This error is Digest Already In Progress。原因在于$digest循环已经在执行了,你再次手动调用了$applyfunction.

    Just remove the redundant call, you can also $apply时判断是否已经在$digest:

    javascriptif(!$scope.$$phase) {
        $scope.$apply();
    }
    

    Look at this question: http://stackoverflow.com/questions/12729122/prevent-error-digest-alrea...

    If you don’t know what $digest is, refer to this article:
    http://harttle.github.io/2015/06/06/angular-data-binding-and-digest.ht...

    reply
    0
  • Cancelreply