O'Reilly logo

AngularJS Directives by Alex Vanston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Keeping it Clean with Scope

"Why do we [scope], Master Wayne? So we can [stay modular and code like a rockstar]"

- Alfred (if he'd been an Angular developer)

As you've likely seen so far, the scope object within Angular serves as the primary intersection point between our data, our view, and the rest of our code. Any property or method that's available on our scope can be accessed and used within our HTML. Likewise, any changes that happen to the data will update the HTML and can trigger other updates within the rest of code, via the $watch method that we've already used several times.

Those qualities of scope pervade nearly all of Angular development. Within a directive however, scoping takes on an even more powerful role, allowing us ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required