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

Configuration options

Now that we have a good basis for how to create a blank directive and attach it to our DOM, let's take a look through the directive definition object, which is the official name for the object returned from the directive factory function. Remember that there are two ways to initialize a directive within the factory function. The first is to return our linking function, as we did earlier, and the second is to use this definition object to provide more fine-grained control over the way our directive functions. Using the definition object, our directive with all the options enumerated looks like the following code:

angular.module('myApp.directives', []) .directive('myAwesomeDirective', ['api', function(api) { //Do any one-time ...

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