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

Using dynamic templates on directives

In this first example we will create a directive using inline templates rendered by the JavaScript inside of the directive. Also, in the example we will simulate the $http.get() method to get the closest example of a real situation.

In addition, we will see an important tip for loading videos from external sources using our application on a local server.

Getting ready

We are still using the Yeoman generator-angm (version 0.2.6) to build the base line application. You can get the code in the examples folder at PacktPub, or open your terminal window and type:

yo angm

Name it dynamic-templates and press Enter, Enter, and Enter..

Tip

The generator-angm (version 0.2.6) uses the new stable version from AngularJS, 1.4.5. ...

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