Implementing Scope Hierarchy
A great feature of scopes is that they are organized in a hierarchy. The hierarchy helps you keep scopes organized and relevant to the context of the view they represent. Also, the $digest()
method uses the scope hierarchy to propagate scope changes to the appropriate watchers and the DOM elements.
Scope hierarchies are created automatically based on the location of ng-controller
statements in the AngularJS template. For example, the following template code defines two <div>
elements that create instances of controllers that are siblings:
<div ng-controller="controllerA"> . . . </div><div ng-controller="controllerB"> . . . </div>
However, the following template code defines controllers ...
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.