Building your own directives
AngularJS allows you to build your own custom directives, which are nothing but an extension to the HTML. They are defined using the ‘directive’ function, and simply replace the element for which they are activated. AngularJS finds the matching elements and processes them once, using its compile() method; it then processes the elements using the link() method of the custom directive based on the scope. It supports the creation of custom directives for the following types of elements. Element directives: It activates once a matching element is encountered. Attribute: It activates once a matching attribute is encountered. CSS: It activates once a matching CSS style is encountered. Comment: It activates once a matching comment is encountered.