The exports property in @NgModule metadata defines which declared components, directives, pipes, or imported modules a feature module makes available to modules that import it. Exported classes must already appear in declarations or imports. section 19.3.2
Exporting a feature component
A store feature module declares StoreComponent and exports it so the root module can use the component after importing StoreModule: @NgModule({ imports: [ModelModule, BrowserModule, FormsModule], declarations: [StoreComponent], exports: [StoreComponent] }) export class StoreModule { } The declarations property makes StoreComponent available inside the feature module; exports extends that availability to importing modules. section 5.4.2
Use the exports property to:
- Expose selected components, directives, and pipes from a feature module. section 19.3.2
- Re-export an imported module type when that module is already listed in imports. section 19.3.2
- Reduce direct imports of shared declarations after consolidating them in a common module. section 19.3.2
Listing 5.17. The contents of the store.module.ts file in the src/app/store folder
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { ModelModule } from "../model/model.module";
import { StoreComponent } from "./store.component";
@NgModule({
imports: [ModelModule, BrowserModule, FormsModule],
declarations: [StoreComponent],
exports: [StoreComponent]
})
export class StoreModule { }
Inspect the complete store.module.ts listing showing imports, declarations, and exports together. section 5.4.2
