Angular 2 ng模块导入 [英] Angular 2 ng module imports

查看:74
本文介绍了Angular 2 ng模块导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在顶部导入文件时,导入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: []被导入的@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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆