且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular2 RC6 - 在我的子模块中导入 BrowserModule

更新时间:2023-11-22 17:57:28

你应该不要在子模块中导入BrowserModule.

You should not import BrowserModule in submodule.

在根模块中导入BrowserModule,在子模块中导入CommonModule.

Import BrowserModule in the root module and CommonModule in submodules.

Plunker 示例

另见https://angular.io/docs/ts/latest/cookbook/ngmodule-faq.html#q-browser-vs-common-module

不要在任何其他模块中导入 BrowserModule.功能模块和延迟加载模块应该导入 CommonModule 代替.他们需要通用指令.他们不需要重新安装应用范围的提供程序.

Do not import BrowserModule in any other module. Feature modules and lazy loaded modules should import CommonModule instead. They need the common directives. They don't need to re-install the app-wide providers.