Define Directives in AngularJS?

AngularJS directives are used to extend HTML. In simple words, AngularJS are DOM Manipulator that tells AngularJS’s HTML compiler ($compile) to provide a specific behavior to DOM element (such as an attribute, element name, comment or CSS class).

AngularJS comes with a built-in set of directives for e.g. ng-app, ng-init, ng-model. Most of the directives have a prefix ng- except a, form, textarea, input, script and select. AngularJS also allows us to create our own directives. We will discuss about the custom directive in the next post.

Note: The directives are named in camelCase but are written in hyphen-delimited lower case when applied in html elements as attributes.

Join Discussion

This site uses Akismet to reduce spam. Learn how your comment data is processed.