I don't understand how to use $scope.$watch
and $scope.$apply
. The official documentation isn't helpful.
What I don't understand specifically:
- Are they connected to the DOM?
- How can I update DOM changes to the model?
- What is the connection point between them?
I tried this tutorial, but it takes the understanding of $watch
and $apply
for granted.
What do $apply
and $watch
do, and how do I use them appropriately?
There are
$watchGroup
and$watchCollection
as well. Specifically,$watchGroup
is really helpful if you want to call a function to update an object which has multiple properties in a view that is not dom object, for e.g. other view in canvas, webGL or server request. Here, the documentation link.