Directives
In this lesson, we will look at directives, some commonly used directives, and how we can create custom attribute directives.
`
A directive is used when you wish to extend the behavior of any HTML element. It helps us add or extend the behavior of any element in terms of its layout, appearance, etc. In the previous lesson, we created a component directive. A component is also a type of directive, but it has a template of its own.
Directives work the same way we use selectors to reference components.
Angular has the following different types of directives:
- Component directives, which we have already seen.
- Attribute directives
- Structural directives
Attribute directives
These directives help us extend the behavior or appearance of the elements inside the template. The most commonly used attribute directive is NgStyle
. This helps you change the style of several elements in one go. We will also look at creating custom attribute directives in Angular ...