InterviewHubPRO
Section Overview
Q60

Question 60 of 283

Part 2: HttpClient, RxJS Observables & Angular Elements (36 - 62)

21%
Angular & Signals (283 Qs)•Part 2: HttpClient, RxJS Observables & Angular Elements (36 - 62)

What are the various kinds of directives?

There are mainly three kinds of directives:

  1. Components — These are directives with a template.
  2. Structural directives — These directives change the DOM layout by adding and removing DOM elements.
  3. Attribute directives — These directives change the appearance or behavior of an element, component, or another directive.

Practical Code Example

typescript
// Three Kinds of Directives in Angular:
// 1. Components: Directives with their own template (@Component)
// 2. Structural Directives: Manipulate DOM layout (*ngIf, *ngFor, @if, @for)
// 3. Attribute Directives: Modify appearance or behavior of host element ([ngClass], appHighlight)