interview community logo

What are the types of directives
1 answer

what are the types of directives?

and what are the built-in example for each of them?

Angular Robert Isaac asked 9 months ago


there are 3 types of directives:

  1. component (example router-outlet) is the main building block for Angular applications, they can be used in a reusable form with a selector and inputs, or being bind to a route with params
  2. structural directive (example ngIf) is used to to control if an element should be added or remove from the DOM
  3. attribute directive (example ngClass) is used to change specific behavior of the element applied to (with ngClass for example to add or remove a class for the Element)
Robert Isaac answered 9 months ago loading comments...