Chapter 3AngularJS Scope & Events

Scope Demystified

You have been listening me talk about scopes from the beginning of the book. But now (drum roll, please!) we're going to demystify the AngularJS scope.

Essentially, a scope is nothing but a plain old JavaScript object, and that is just a container for key/value pairs, as follows:

var myObject={name:'AngularJS', creator:'Misko'}

A scope—like other objects—can have properties and functions attached to it. The only difference is that we don't usually construct a scope object manually. Rather, AngularJS automatically creates and injects one for us.

In the Angular world, a scope object is useful for holding model values, which are presented by the view. In our previous example, we attached properties ...

Get AngularJS: Novice to Ninja 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.