我想知道Angular 4中的模块,如果我有这个模块:
@NgModule({
imports: [
...
...
],
declarations: [
OneComponent
],
})
export class OneModule { }
在我的app.modules.ts中,我在导入中使用了这个模块
@NgModule({
imports: [
...
OneModule
...
],
})
export class AppModule { }
这是否意味着OneComponent
在应用模块中声明了?
我遇到了TimeAgoModule包的问题,如果我将其放在OneModule导入中,则OneComponent应该看到时间,但是它说没有定义时间,并且如果我将OneComponent从OneModule声明移动到AppModule声明,则一切都是正确的精细。到底是什么主意?
您需要使用export
OneComponent。
@NgModule({
imports: [
...
...
],
exports: [OneComponent],
declarations: [
OneComponent
],
})
export class OneModule { }
通过导出一个component
,您可以告诉Angle模块该特定模块component
可以在模块外部使用,并且可以在其他模块中重复使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句