Angular 2 Decorator

Angular 2 Decorator

Angular 2 Decorator are functions that are invoked with a prefixed @ symbol, and immediately followed by a class name or parameter or method or property.

Angular 2 Decorator used to supply information about the class, parameter or method.

Angular 2 Decorator is also known as Angular metadata.

You might have noticed in previous posts we have written Angular class with @Component, here @Component() is nothing but a decorator.

List of decorators in Angular

  1. @Component
  2. @NgModule
  3. @Input
  4. @Output
  5. @Injectable

@Component decorator

import { Component } from '@angular/core';
 selector: 'hello-world',
 template: '<h1>Hello World</h1>',
 export class HelloWorldComponent {
 constructor() {}

@NgModule decorator

import { NgModule } from '@angular/core';
 imports: [],
 declarations: [],
 export class CommonModule {
 constructor() {}


Full-stack web and mobile app development company Contact Us : Skype: indore.webcoder Email: Sales: +91 8085506229