What is a decorator in Angular? Name a few.

Angular basics · Freshers

Model answer

A decorator is a function written with @ above a class, property or method that adds metadata or behaviour. Angular uses them to tell the framework what a class is. Examples: @Component marks a component, @Directive a directive, @Pipe a pipe, @Injectable a service, and @Input and @Output mark inputs and outputs in the classic style.

In newer Angular, signal-based functions such as input(), output() and viewChild() replace some property decorators, but the class decorators are still used.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions