Angular 2 ng 模块导入 [英] Angular 2 ng module imports
问题描述
当我们在顶部导入文件时,ngmodule 装饰器的导入元数据有什么意义.两个输入之间的差异.
What is the significance of imports metadata of ngmodule decorator, when we are importing files at top. Difference between both the inputs.
推荐答案
这些导入是完全不同的概念.
These imports are entirely different concepts.
文件顶部的导入是 TypeScript 导入,用于使当前文件已知的类、接口和变量与 Angular2 无关.
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.
@NgModule()
导入是为了使导入的 @NgModule()
知道导入的 exports: []
code>@NgModule() 以便它们在选择器匹配时应用于导入模块的组件.
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.
还有 providers: []
导入的模块被添加到注入器的根范围(仅当模块不是延迟加载时).
Also providers: []
of an imported module are added to the root scope of the injector (only when the module is not lazy loaded).
这篇关于Angular 2 ng 模块导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!