Pra*_*h B 13 components module typescript angular
我有一个名为CustomerInfoModule的功能模块,它导出一个CustomerInfoComponent.见下文.
import {NgModule} from '@angular/core'
import {RouterModule} from '@angular/router'
import {CustomerInfoComponent} from './customer-info.component'
@NgModule({
declarations:[CustomerInfoComponent],
exports:[CustomerInfoComponent]
})
export class CustomerInfoModule{
}
Run Code Online (Sandbox Code Playgroud)
我想在MissedCollectionsComponent中导入和使用此CustomerInfoComponent.我收到打字稿错误
'.module''没有导出的成员'CustomerInfoComponent'
.
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{
}
Run Code Online (Sandbox Code Playgroud)
根据Angular2文档,它说:
"我们导出ContactComponent,以便导入ContactModule的其他模块可以将其包含在组件模板中." 链接
从模块导入组件并在另一个模块中使用它是不合逻辑的.我错误地认为/或缺少某些东西?
因为您从模块文件导入,所以您可以执行类似的操作。
客户信息.module.ts
import {CustomerInfoComponent} from './customer-info.component';
export {CustomerInfoComponent};
Run Code Online (Sandbox Code Playgroud)