Explain Directive in Angular?

The Angular directive helps us to manipulate the DOM. You can change the appearance, behavior, or layout of a DOM element using the Directives. They help you to extend HTML

There are three types of directives in Angular:

COMPONENT DIRECTIVE: Components are special directives in Angular. They are the directive with a template (view)

STRUCTURAL DIRECTIVE: Structural directives can change the DOM layout by adding and removing DOM elements.

All structural Directives are preceded by the Asterix symbol :

  • ngFor
  • ngSwitch
  • ngIf

ATTRIBUTE DIRECTIVE: An attribute or style directive can change the appearance or behavior of an element

  • ngModel
  • ngClass
  • ngStyle