Custom Attribute directives can be
attached to HTML elements like input, span etc to provide more features / functionalities
to the element. Custom directives can be created using the ng generate
directive command. Similar to components which use the @Component decorator, a directive uses the @Directive decorator. The directive class can implement the
life-cycle hooks and alter the bahaviour of the directives.
In the following example let us create a very simple Highlighter directive which can be used in a label/span tag and will highlight the label with a color. Let us begin by creating a new directive using the ng generate command as follows.
In the following example let us create a very simple Highlighter directive which can be used in a label/span tag and will highlight the label with a color. Let us begin by creating a new directive using the ng generate command as follows.