Directives overview
There are three kinds of directives in Angular:
- Components—directives with a template.
- Structural directives—change the DOM layout by adding and removing DOM elements.
- Attribute directives—change the appearance or behavior of an element, component, or another directive.
Components are the most common of the three directives
A component class that handles data and functionality. In the previous section, the product data and the
share()
method in the component class handle data and functionality respectively.An HTML template that determines the UI. In the previous section, the product list's HTML template displays the name, description, and a "Share" button for each product.
Component-specific styles that define the look and feel. Though product list does not define any styles, this is where component CSS resides.
Structural Directives _change the structure of the view. Two examples are NgFor and NgIf
Attribute directives are used as attributes of elements. for example, can change several element styles at the same time.
.