In this video Iftach Bar shows how you could force a digest loop from the browser's console and why would you want to do that.
- [Instructor] Another thing you might want to do…is to force a digest from the console.…Just to run a digest and see what happens.…We can also combine it with getting the scope…like we saw in the previous video.…In the previous video, we saw a bug…that when we click the Bad Button,…the binding doesn't change.…We want to force a digest and see if it solves the issue.…I'm going to inspect the div here…and I'm going to go to the console…and write angular.element($0)scope.…
Now that I have the scope, I can force a digest…by just running the function $apply.…When I do that, I see that the bug was solved.…We can also see that the digest loop actually happened.…Because we see the watchers print into the console.…This method is also useful before you write some…for the action code.…For example, if I want to change some of the variables…on the scope, I can do that from the console,…and I can run a digest to see what happens.…
Let's try to do that.…I'm going to get the scope again…and I'm going to get the vm from it.…I'm going to change the value of force to be 500.…
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.