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

Handsontable JavaScript Spreadsheet Most popular component for web apps

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 Deering

Sam Deering

Sam is a web developer, online entrepreneur and investor. In his spare time he enjoys coding, playing chess and sharing what he learns with others.

Leave a Reply

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