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

Mixing different content on templates

Continuing with the previous example of organizing code, we can continue and create as many templates as necessary for the dynamic directives.

We will see in this example the use of ng-include, a built-in AngularJS directive using external templates, created in specific files, thus facilitating easy maintenance and scalability.

Also, we will see a different way to load the content using the $resource service in our controller function.

Getting ready

The baseline code for this recipe is the same as in the previous chapter. We just need to create additional files.

For the purpose of this book, we will place the new directive in the same file as the previous one. In a real application, we strongly recommend the use ...

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