Angular 2 ng module imports

断了今生、忘了曾经 提交于 2019-12-01 09:00:26

问题


What is the significance of imports metadata of ngmodule decorator, when we are importing files at top. Difference between both the inputs.


回答1:


These imports are entirely different concepts.

The imports at the top of the file are TypeScript imports to make classes, interfaces and variables known to the current file and are not related to Angular2.

The @NgModule() imports are to make exports: [] of the imported @NgModule()s known to the importing @NgModule() so that they applied to components of the importing module if selectors match.

Also providers: [] of an imported module are added to the root scope of the injector (only when the module is not lazy loaded).



来源:https://stackoverflow.com/questions/39947200/angular-2-ng-module-imports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!