Skip to content

Instantly share code, notes, and snippets.

@huangzhuolin
Last active July 3, 2018 08:53
Show Gist options
  • Save huangzhuolin/a75338029e81454c421b1f7c58fe70e3 to your computer and use it in GitHub Desktop.
Save huangzhuolin/a75338029e81454c421b1f7c58fe70e3 to your computer and use it in GitHub Desktop.
[angularjs directives] #angularjs

Directives

refs

https://docs.angularjs.org/guide/directive

Definition

At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.

matching directives

  1. <input> element matches the ngModel directive <input ng-model="foo">
  2. <input> element matches ngModel <input data-ng-model="foo">
  3. <person> element matches the person directive <person>{{name}}</person>

normalization

  1. Strip x- and data- from the front of the element/attributes.
  2. Convert the :, -, or _-delimited name to camelCase.

directive types

  • E: element names
  • A: attributes
  • C: class names
  • M: comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment