Types of Angular Decorators | @Component | @NgModule | @Input | @output | injectable | Part-6

Опубликовано: 04 Октябрь 2024
на канале: Code with Salman
286
8

Decorators are the features of Typescript and are implemented as functions

There are many built-in decorators are available in angular. Some of them are as follows:

@NgModule to define a module.

@Component to define components.

@Injectable to define services.

@Input and @Output to define properties, etc.

Class Decorators: @Component and @NgModule

Property Decorators: @Input and @Output (These two decorators are used inside a class)

Method Decorators: @HostListener (This decorator is used for methods inside a class like a click, mouse hover, etc.)

Parameter Decorators: @Inject (This decorator is used inside class constructor).
Components are the most basic UI building block of an Angular app. An Angular app contains a tree of Angular components. Angular components are a subset of directives, always associated with a template. Unlike other directives, only one component can be instantiated for a given element in a template.