Properties of the @NgModule decorator

If you take a look at the app.module.ts file in the example application that we started building in Chapter 4, Routing, you can see that there are four parameters in the @NgModule annotation on our AppModule class. Let's take a quick look at these four and what we use them for:

  • Declarations: This is where we list the components and directives that we will need to package in this NgModule.
  • Imports: These make the exported declarations of other modules available to our NgModule.
  • Providers: This is where we list services and values so that they become known to dependency injection (DI). They are added to the root scope and are injected to other services or directives that have them as a dependency. We're going to cover DI in Chapter 12, Integrating Backend Data Services.
  • Bootstrap: This is where we list the component that we want Angular to Bootstrap upon application startup.

There can only be one NgModule in our application where we make use of the Bootstrap parameter—since the bootstrapping process starts with only one module.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.106.100