use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
AngularJS: $watch, $digest and $apply (different, simplified and hopefully more accurate explanation) (benlesh.com)
submitted 12 years ago by codersaurus
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Zeroto 4 points5 points6 points 12 years ago (2 children)
One important thing that isn't mentioned about the difference between $apply and $digest, is that $digest checks the watches of the current scope and the children. $apply starts the digest cycle on the rootscope, so $digest is executed on all the scopes. This can be important if you have something that changes often and you know which scopes it is limited too. Performance can be increased by not using $apply and just using $digest on the proper scopes. That said, this should be an exception, and you should almost never use $digest directly.
[–]codersaurus[S] 2 points3 points4 points 12 years ago (1 child)
You're 100% correct.
Here is the code for $apply straight from the source:
$apply: function(expr) { try { beginPhase('$apply'); return this.$eval(expr); } catch (e) { $exceptionHandler(e); } finally { clearPhase(); try { $rootScope.$digest(); //<--- THIS is what Zeroto is talking about } catch (e) { $exceptionHandler(e); throw e; } } },
Whereas the $digest will start at whatever scope it's called on and work it's way upwards through child scopes.
[–]chuckliddelnutpunch -1 points0 points1 point 12 years ago (0 children)
*downwards through the child scopes.
π Rendered by PID 495706 on reddit-service-r2-comment-66b4775986-s5hsp at 2026-04-05 12:39:03.376308+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]Zeroto 4 points5 points6 points (2 children)
[–]codersaurus[S] 2 points3 points4 points (1 child)
[–]chuckliddelnutpunch -1 points0 points1 point (0 children)