Skip to main content

What are Directives in Angular?

Entry Angular
Quick Answer Directives are classes that add behavior to DOM elements. Three types: Component (a directive with a template), Structural (*ngIf, *ngFor, *ngSwitch - alter DOM structure by adding/removing elements), Attribute ([ngClass], [ngStyle], custom - modify element appearance or behavior without changing structure). Custom directives encapsulate reusable DOM behavior.

Answer

Directives are instructions applied to DOM elements.

Types include structural directives (*ngIf, *ngFor) and attribute directives (ngClass, ngStyle).

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice