$apply already in progress error

后端 未结 11 1265
暗喜
暗喜 2020-11-29 17:53

Stack trace:

Error: $apply already in progress
at Error ()
at beginPhase (file:///android_asset/www/built.min.js:7:22740)
at Object.Scope.$a         


        
11条回答
  •  星月不相逢
    2020-11-29 18:36

    If scope must be applied in some cases, then you can set a timeout so that the $apply is deferred until the next tick

    setTimeout(function(){ scope.$apply(); });
    

    or wrap your code in a $timeout(function(){ .. }); because it will automatically $apply the scope at the end of execution. If you need your function to behave synchronously, I'd do the first.

提交回复
热议问题