Chapter 10AngularJS Directives

The Directive API is one of the coolest features of AngularJS. Now that you've been developing in AngularJS for some time, you've come across many simple directives, such as ng-repeat, ng-show, ng-model, etc. But when you come to develop real world apps you'll most likely need custom directives. This chapter will teach you how to build these and implement them in our demo app.

What Are Directives, Really?

A directive is something that attaches special behavior to a DOM element and teaches it awesome tricks! Let's take the example of the built-in ng-repeat directive: What this does is attach special behavior to a DOM element by repeating it multiple times. Similarly, ng-show and ng-hide conditionally show or hide ...

Get AngularJS: Novice to Ninja now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.