Enter Your Email Address to Watch This Lesson

Your link to unlock this lesson will be sent to this email address.

Unlock this lesson and all 983 of the free egghead.io lessons, plus get Angular 1.x content delivered directly to your inbox!



Existing egghead members will not see this. Sign in.

Directive Definition Object (DDO)

1:19 Angular 1.x lesson by

Directive Definition Objects are used to configure AngularJS directives. Be sure to check out our Directive Definition Object Cheat Sheet.

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

Directive Definition Objects are used to configure AngularJS directives. Be sure to check out our Directive Definition Object Cheat Sheet.

This function that we just set up is what's called a link function, and it's actually a very small part of a larger API. If I cut this and instead I return an object and it has a property of link with that function, you'll see that this will behave the exact same way. Now this object that we are returning here is called the directive definition object, or DDO if you want an acronym for it. There's plenty of things on here for you to configure.

I want to emphasize that the things on here such as restrict, such as template, such as templateURL, and priority, and all the other things you can put on here are really a matter of configuration. A lot of the things you'll just have to get used to, you'll memorize what you put in there. It's not a lot of writing code. When it comes to writing code a lot of it ends up in either this link function or a controller function which we'll talk about later, and in rare scenarios, when you need to use it, a compile function. But the rest of it such as restrict and other is basically configuration which you just really have to memorize.

You'll be referring to the docs or these reference videos as you write your directive definition object.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?