【发布时间】:2017-06-17 02:08:19
【问题描述】:
我有一个名为 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{
}
我想在 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{
}
根据 Angular2 文档,它说:
'我们导出 ContactComponent 以便其他模块导入 ContactModule 可以将它包含在他们的组件模板中。 link
从一个模块导入组件并在另一个模块中使用它是否不合逻辑。我是不是想错了/或错过了什么?
【问题讨论】:
标签: angular typescript module components