How to check if the digest cycles have stabilized (aka “Has angular finished compilation?”)

后端 未结 1 1115
青春惊慌失措
青春惊慌失措 2021-02-10 05:23

tl;dr: The initial question was \"How to trigger a callback every digest cycle?\" but the underlying question is much more interesting and since this answers bo

相关标签:
1条回答
  • 2021-02-10 06:17

    I actually do not know if my advice will answer your question, but you could simply pass a listener to the $watch function which will be called on each iteration:

    $rootScope.$watch(function(oldVal, newVal){
        // add some logic here which will be called on each digest cycle
    });
    

    Have a look here: http://docs.angularjs.org/api/ng/type/$rootScope.Scope#$watch

    0 讨论(0)
提交回复
热议问题