In this video Iftach Bar explains the difference between calling the method $apply and the method $digest.
- [Instructor] There is another method on $scope…that is called $digest.…And it is very un-intuitive…that the function we need to call…to initiate the digest loop is $apply…and not $digest.…$apply and $digest…are actually quite similar.…The difference is that $digest…will only run the watchers…defined on the current scope…and all the sibling scopes,…while $apply will run all the watchers…in our application.…
$digest is just a bit more efficient…since it will run on a subset of the watchers…in the application…and not on all of them.…It is also more dangerous…because if one of those sibling scopes…changed a variable…on a scope of some other unrelated controller…we will get out of synch.…Let's go back to our code…and define the internal controller again.…I'll grab the module.…
I'll define the controller.…I'll inject it with scope.…I'm going to move the jQuery click handler…to the internal controller.…In order to change the dream variable…from the internal controller,…I'll need to access the parent controller.…I'm going to remove the line from a previous video…
This advanced AngularJS course helps you explore the connected worlds of $scope and the digest cycle. Instructor Iftach Bar explains scope and inheritance, goes behind the scenes of the digest loop, and teaches both manual and automatic data binding approaches. Plus, learn how to integrate external libraries, diagnose performance issues, and debug your applications.
- $scope and controllers
- $scope built-in variables and methods
- $scope prototype inheritance
- Manual data binding with $scope.$watch
- The digest loop
- Get the $scope in the console
- Forcing $digest
Skill Level Advanced
AngularJS 1: Building a Data-Driven Appwith Ray Villalobos2h 15m Intermediate
1. Scope Basics
2. Manual Data Bindings
3. The Digest Loop
4. Tips for Debugging Angular in the Console
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.