In this video Iftach Bar shows what happens when the digest loop becomes infinite and how Angular catches it and deals with it.
- [Instructor] In the previous video, we dived into…how the digest loop operates.…We saw that the digest loop may repeat several times…and this is the depth of the digest loop.…What do you think will happen if we create an infinite…loop?…Let's do that.…Let's add another watcher here that will watch over…vm.force in US dollars…and whenever it changes we will change…the value of force to be the value of force in US dollars…times two.…
So let's assume the value of force is 30,…this watch will run and will change the value of…force in US dollars to 30 times 10, which is 300.…Then this watch will run and will change the value of…force to 300 times two which is 600.…And then this watcher will run again, and will…change the value from 600 times 10 to 6000.…And again, and again, and again, infinitely.…This may actually make the browser stuck.…
Let's see how Angular handles it.…As we can see the browser is not stuck and the…values reach the significant level but we also…see an error in the console.…We notice that the digest loop ran 10 times and…
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.