What does $scope.$apply() do?

后端 未结 3 1906
-上瘾入骨i
-上瘾入骨i 2020-12-19 14:04

I\'ve been using $scope.$apply() to update the bindings for my models when I receive data through websockets in my Angular apps and it works. But what does it a

3条回答
  •  囚心锁ツ
    2020-12-19 14:35

    Simply put it:

    1. (Optionally) Processes an expression you pass to it as an argument.
    2. Calls $digest() on the $rootScope.

    I also wrote a blog entry about what $apply, $digest and $watch do and how they work together

    I hope that helps.

提交回复
热议问题