Saturday, 7 May 2016

Post 47: AngularJS directives

You can define directives in AngularJS as
- Element ("E"):
<my-directive></my-directive>
notice that we don't use self closing tags, i.e. <my-directive/> because some browsers can't handle self-closing tags

Use this for UI widgets.

- Attribute ("A"):
<h3 my-directive></h3>

Use this for mixin behaviours, e.g. tooltip

- Class name ("C")

<h3 class="my-directive"></h3>

- Comment ("M")
  <!-- directive: my-directive -->
Tweet