I think directives are the most important bit in an Angular application. There are 3 types of directive in Angular which is listed below.
- Component Directive
- Attribute Directive
- Structural Directive
Component Directive:
The component directive is something which is the core thing of angular application. We create components by using @Component decorator. The best example of component directive is AppComponent.
1
2
3
4
5
6
7
8
9
10
|
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
|
Attribute Directive:
Creating a directive is pretty similar to a component, we user @Directive decorator for creating the directives. Attribute directives are used as attributes of elements. Let me explain this with an example: ...