🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///
Total XP: 0|💻 angular XP: 0

Directives Intro in Angular

Learn the taxonomy of Angular directives and understand the fundamental differences between components, structural markers, and attribute modifiers.

LOADING ENGINE...

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Directives are the special markers in your HTML that tell Angular to attach specific behavior to DOM elements or even transform the DOM structure entirely.

1The Directive Trinity

Angular categorizes directives into three types. First, Components are the most common; they manage a specific patch of screen. Second, Structural Directives (*ngIf, *ngFor) are the architects; they physically add or remove elements from the DOM. Third, Attribute Directives ([ngClass], [ngStyle]) are the decorators; they modify the attributes and styles of existing elements without changing the structure.

2Asterisk vs Brackets

The syntax of a directive tells you its purpose. An asterisk (*) like in *ngIf indicates that the directive is structural and will use a <ng-template> behind the scenes to manage the layout. Square brackets [] like in [ngClass] indicate that the directive is an attribute directive, treating the directive name as a property of the host element.

?Frequently Asked Questions

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Lesson Glossary

[01]Directive

A marker on a DOM element that tells Angular to attach behavior or transform the DOM.

Code Preview
Marker

[02]Structural Directive

A directive that changes the DOM layout by adding and removing elements.

Code Preview
*ngIf

[03]Attribute Directive

A directive that changes the appearance or behavior of an element, component, or another directive.

Code Preview
[ngClass]

[04]Component Directive

A directive with an associated template; the most common directive type.

Code Preview
@Component

[05]ng-template

An Angular element used for rendering HTML that isn't displayed by default, used by structural directives.

Code Preview
<ng-template>

[06]Selector

The attribute name or CSS selector used to apply a directive to an element.

Code Preview
Target

Continue Learning