O'Reilly logo

AngularJS Directives Cookbook by Fernando Monteiro

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

Building a directive as an interface component

An important observation when we talk about directives and interface components is to understand that this is just an analogy between them, since the following doubt may arise: are not they the same thing? Not exactly.

The component is a code snippet that can be connected to any code block and still behave as expected. Even in different code blocks.

A directive often receives or handles data from external sources, so for it to behave the same way, interacting with different data sources needs some adjustments.

Here, we will see a way to create a directive and encapsulate its contents to get the same result.

Getting ready

Just as we did in the previous chapters, we will continue using the same application ...

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