Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Directive Definition Object (DDO)

    John LindquistJohn Lindquist

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

    angularjsAngularJS
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Man 1: 00:00 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.

    00:32 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.

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

    Discuss

    Discuss