Built-in directives

Directives encapsulate coded behaviors that can be applied as attributes to HTML elements or other components:

Name Syntax Purpose
Structural Directives

*ngIf

*ngFor

*ngSwitch

Controls structural layout of the HTML and if elements get added or removed from the DOM
Attribute Directives

[class]

[style]

[(model)]

Listens to and modifies the behavior of other HTML elements, attributes, properties, and components, such as CSS classes, HTML styles, and HTML form elements

Structural Directives Source: https://angular.io/guide/structural-directives

Attribute Directives Source: https://angular.io/guide/template-syntax#built-in-attribute-directives

Get Angular 6 for Enterprise-Ready Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.