Angularjs directives choose restrict “A” instead of “E”

So in AngularJS do you choose “A” or “E”? Attribute or element in a directive? Let’s have a look.

Element Example.

Attribute Example.

Attribute Example 2

So which one do you choose? and more importantly, why?

  1. Element essentially means creating a custom HTML element which can be used like a new HTML tag.
  2. Attribute basically means using a div (or such) and adding the element as an attribute to that already established HTML tag.
  3. Older browsers (inc IE) can’t handle custom directives as elements

What about “C” and “M”?

There is also “C” which is Class.

And “M” which is Comment


Sam is a web developer, online entrepreneur and investor. In his spare time he enjoys coding, playing chess and love to share what he learns.

Leave a Reply

Your email address will not be published. Required fields are marked *