Rupert  Beatty

Rupert Beatty

1626080060

Custom Attribute Directive in Angular

Custom Attribute Directive Implementation in 5 minutes

Technofunnel presents another article on how to create Custom Attribute Directives in Angular. These directives are just like any other attribute like “id”, “class” and “name” that can be attached to an element. Once the directive is applied over an element, the functionality in the directive is applied to it.

Benefits of Custom Attribute Directive

  • Can create common functionality applied over multiple elements
  • Can manipulate the appearance and behavior of a component
  • It can manipulate the DOM properties of an element
  • Elements can be hidden or flown on the basis of certain conditions

Creating a Simple Attribute Directive

In the above example, we will be creating a custom attribute directive that will update the color of the component to “green”. We will name this custom attribute “applyColor”.

#react #javascript #angular

Custom Attribute Directive in Angular