Angular FAQ: Top Questions
38. What is the difference between attribute and structural directives?
Attribute directives change the appearance or behavior of an element, component, or another directive. Structural directives change the DOM layout by adding or removing elements.
- Attribute:
ngClass
,ngStyle
- Structural:
*ngIf
,*ngFor
<div [ngClass]="{active: isActive}"></div>
<div *ngIf="isVisible">Visible Content</div>