In this video Iftach Bar explains about the usage of $rootScope, why people use it, and when not to use it.
- [Narrator] We now understand…that every Scope has a parent scope.…But that might raise the question,…of where do we stop?…And the answer is, at root scope.…When we create a new ng-app,…a root scope is generated with it.…Every Scope is a descendant of root scope.…Many old angular applications use root scope…to communicate between different parts of the application.…Since all controllers can inject a root scope and use it,…and since all Scopes inherit from root scope eventually,…it is very easy to share data…between Scopes by putting variables on the root scope.…
For example, on one controller,…I can inject the $rootScope, and sets a variable called,…variableEverybodyAccess on the $rootScope.…And in another controller,…I can just inject the $scope,…and access variableEverybodyAccess…from the $scope of this controller.…Since this $scope inherits eventually…from the $rootScope, using $rootScope…to communicate between different parts…of the application should be avoided as much as you can.…This is a very bad practice that can cause…
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.