What are Decorators?

Sharad Jaiswal
Sharad Jaiswal

Posted On: Feb 22, 2018


    1 Answer Written

  •  Sharad Jaiswal
    Answered by Priyag Chaudhary

    Decorator in Angular 2 is a way of adding annotations and it also adds metadata to accessor, class declaration, parameter, method, and property. In Angular v2 and above everything is a class so decorators are used for differentiating the class usage. Decorators are also known as the Meta Data and are generally prefixed with the symbol @. There are different kinds of decorators available in Angular 2 like @directive, @injectable, @NgModule, etc.


    An Angular built-in decorator component

              selector : 'app-root', 
             template : '<p>Simple Angular Component</p>' 

    In the example above class, there is a component decorator if you delete this decorator then the class will become blank.

Related Questions

Please Login or Register to leave a response.

Related Questions