angular 2+ module中exports的作用

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
  declarations: [
  ],
  imports: [
    CommonModule
  ],
  exports: [ //<-这个数组什么用?
  ]
})
export class CustomModule { }

自定义module的时候,这个exports有什么用?把几个自定义的component只要放在declarations中就可以了,不放到exports中也可以用。而自定义的pipe如果不放到exports中就访问不到,求解!

阅读 4.6k
2 个回答

不exports的组件,只能在当前模块中(也就是 declarations 中有此组件的那个模块)中使用。
其他模块是无法使用的。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进