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

Attachment styles

No, we're not talking about relationships here. Directives can be invoked from within your HTML in multiple ways, though it's up to the developer to decide which ones they will allow. When developing your own directive, you can control which methods you want to utilize through the restrict property, using a subset of EACM (standing for element, attribute, class, comment).

By far, the most common method for invoking a directive is through an attribute, in large part because it's the default if the restrict property is left undefined. It's the method you've seen me use so far in all the examples, and outside of this section, all other examples we'll use this method as well. Declaring a directive via an attribute protects you from ...

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