作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个名为 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。我收到 typescript 错误
'.module"' has no exported member '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 文档,它说:
'We export the ContactComponent so other modules that import the ContactModule can include it in their component templates.' link
从一个模块中导入组件并在另一个模块中使用它是不合逻辑的吗?我是不是想错了/或错过了什么?
最佳答案
因为您是从模块文件导入的,所以您可以这样做。
客户信息.module.ts
import {CustomerInfoComponent} from './customer-info.component';
export {CustomerInfoComponent};
关于 Angular 2 : export component on a module and import and use it inside a module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41960959/
我是一名优秀的程序员,十分优秀!