Angular 2: export a component to a module and import and use it inside the module

I have a CustomerInfoModule function module that exports a CustomerInfoComponent. see below.

import {NgModule} from '@angular/core' import {RouterModule} from '@angular/router' import {CustomerInfoComponent} from './customer-info.component' @NgModule({ declarations:[CustomerInfoComponent], exports:[CustomerInfoComponent] }) export class CustomerInfoModule{ } 

I want to import and use this CustomerInfoComponent inside MissedCollectionsComponent. I get typescript error

'. module "'does not have an exported CustomerInfoComponent element

.

 import {NgModule} from '@angular/core' import {RouterModule} from '@angular/router' import {MissedCollectionsComponent} from './missed-collections.component' import {CustomerInfoComponent} from '../shared/customer/customer-info.module' @NgModule({ imports:[RouterModule.forChild([ {path:'missedcollection',component:MissedCollectionsComponent}, {path:'missedcollection/customerinfo',component:CustomerInfoComponent} ]), CustomerInfoModule], declarations:[], exports:[] }) export class MissedCollectionsModule{ } 

According to Angular2 documentation it says:

'We export ContactComponent so that other modules that imported ContactModule can include it in their component templates. ' link

Is it not logical to import components from a module and use it inside another module. Am I mistaken when thinking about what / or is missing?

+6
source share
1 answer

because you are importing from a module file, you can do something like this.

client-info.module.ts

 import {CustomerInfoComponent} from './customer-info.component'; export {CustomerInfoComponent}; 
+2
source

Source: https://habr.com/ru/post/1014597/


All Articles