Angular Directives

Last Updated on May 20, 2022
Angular Directives

Angular Directives

In Angular directives helps to manipulate the HTML DOM. Directives that help to add additional behavior to any of the controller or HTML tag elements or layout of the DOM. There are different kinds of directives in Angular.

  • Component Directive
  • Structural Directive
  • Attribute Directive

Component Directive - This type of directive is the most commonly used directive. This type of directive is used with a template.

Structure Directive - This type of directive can change the DOM layout by adding or removing the elements. Following are some of the commonly used structure directives.

  • ngIf
  • ngFor
  • ngSwitch

Attributes Directive - This type of directive can change the appearance or behavior of an element. This is also known as a style directive. Following are some of the commonly used structure directives.

  • ngClass
  • ngModel
  • ngStyle