Easy concepts of Angular 2.x +

Dev Singh. July 01, 2018 Comments

To learn AngularJS 2.x + learn the below concepts decorators and typescript classes.


Module Decorator

  declarations: [
    AppComponent, TestComponent
  imports: [
    BrowserModule, HeaderModule, RoutingModule,
  exports: [],
  providers: [UserService],
  bootstrap: [AppComponent]

Component Decorator

  selector: 'app-blog',
  templateUrl: './blog.component.html',
  styleUrls: ['./blog.component.css'],
  providers: [HttpService],

Pipe Decorator

  name: 'safeHtml'

Directive Decorator

  selector: '[tagDirective]'


Above all are the Decorators of angularJS to decorate the typescript class into angular module,component,pipe,directive etc. The classes who has decorators need to be declared in the declarations part of @ngModule and those who have not decorators only typescript casses need to be put in the providers of @ngModule (global all over module) or @Component Decorators.

You cannot declare single decorator like component,pipe etc. in multiple modules for this you need to make a shared module and export the decorators in the shared module and import the shared modules on other modules.

  • angular2
  • angular4
  • angular5
  • angular6