Directives
Angular offers two kinds of built-in directives: attribute directives and structural directives.
Last updated
Was this helpful?
Angular offers two kinds of built-in directives: attribute directives and structural directives.
Last updated
Was this helpful?
Attribute directives listen to and modify the behavior of other HTML elements, attributes, properties, and components. You usually apply them to elements as if they were HTML attributes, hence the name.
Many NgModules such as the and the define their own attribute directives. The most common attribute directives are as follows:
—adds and removes a set of CSS classes.
—adds and removes a set of HTML styles.
—adds two-way data binding to an HTML form element.
Structural directives are responsible for HTML layout. They shape or reshape the DOM's structure, typically by adding, removing, and manipulating the host elements to which they are attached.
This section is an introduction to the common built-in structural directives:
—conditionally creates or destroys subviews from the template.
—repeat a node for each item in a list.
—a set of directives that switch among alternative views.