angular6 NgModule中定义模块module
用这个@NgModule()这个decorator ,放在一个class的上面,这个class一个一个module了
@NgModule() 里面的参数是一个对象,用来配置的,声明这个module里面的一些co'mponents, directives, pipes....
https://stackoverflow.com/questions/40393701/what-actually-is-ngmodule-in-angular
--------------------------------------------------------------
Angular NgModules differ from and complement JavaScript (ES2015) modules. An NgModule declares a compilation context for a set of components that is dedicated to an application domain, a workflow, or a closely related set of capabilities. An NgModule can associate its components with related code, such as services, to form functional units.
An NgModule is defined by a class decorated with @NgModule(). The @NgModule() decorator is a function that takes a single metadata object, whose properties describe the module. The most important properties are as follows.
declarations: The components, directives, and pipes that belong to this NgModule.
exports: The subset of declarations that should be visible and usable in the component templates of other NgModules.
imports: Other modules whose exported classes are needed by component templates declared in this NgModule.
providers: Creators of services that this NgModule contributes to the global collection of services; they become accessible in all parts of the app. (You can also specify providers at the component level, which is often preferred.)
bootstrap: The main application view, called the root component, which hosts all other app views. Only the root NgModule should set the bootstrap property.
-----------------------------
First of all, have another read of https://angular.io/docs/ts/latest/guide/ngmodule.html and definitely https://angular.io/docs/ts/latest/cookbook/ngmodule-faq.html as well.
An @NgModule does all the magic setup. It sets up the dependency injection, pulls in any 3rd party modules that it uses, declares all the Components/Directives/Pipes/etc. that are used within the module, exposes some of those Components etc. to other modules, sets up the routing for the module, and sets up any "boostrap" components that can be used as the root Component.
There's two types of modules. First, there's your 'Root module', which is the entry point of your app. You can technically put everything in your app into just one module.
Then there's 'Feature modules', which are used for separation of concerns during development, but also for things like lazy-loading of parts of the app. This is more of an issue for larger apps, but it doing it early can certainly help you set things up "right".
angular6 NgModule中定义模块module的更多相关文章
- 通俗理解ABP中的模块Module
网上有不少文章说ABP的模块,有的直接翻译自官网介绍,有的分析Modlue的源代码,有的写一通代码,没什么注释,很少有能通俗说清的.那么,有两个问题:1.ABP中的模块到底是什么?2.搞这个东西是干嘛 ...
- yiic模块module使用
模块是一个独立的软件单元,它包含 模型, 视图, 控制器 和其他支持的组件. 在许多方面上,模块看起来像一个 应用.主要的区别就是模块不能单独部署,它必须存在于一个应用里. 用户可以像他们访问普通应用 ...
- Lua中的模块与包
[前言] 从Lua5.1版本开始,就对模块和包添加了新的支持,可是使用require和module来定义和使用模块和包.require用于使用模块,module用于创建模块.简单的说,一个模块就是一个 ...
- python 历险记(五)— python 中的模块
目录 前言 基础 模块化程序设计 模块化有哪些好处? 什么是 python 中的模块? 引入模块有几种方式? 模块的查找顺序 模块中包含执行语句的情况 用 dir() 函数来窥探模块 python 的 ...
- Golang 模块(Module)官方手册
官方原文: https://github.com/golang/go/wiki/Modules Go 1.11包括此处建议的对版本模块的初步支持.模块是Go 1.11中的实验性加入功能,并计划纳入反馈 ...
- Node中的模块引入机制
1.如果模块在当前目录下,可以通过下面语句将模块引入进来,注意需要使用 "./"表示当前路径 const currency = require('./currency'); ←-- ...
- node (02 CommonJs 和 Nodejs 中自定义模块)顺便讲讲module.exports和exports的区别 dependencies 与 devDependencies 之间的区别
CommonJS 规范的提出,主要是为了弥补当前 JavaScript 没有标准的缺陷.它的终极目标就是:提供一个类似 Python,Ruby 和 Java 语言的标准库,而不只是停留在小脚本程序的阶 ...
- Lua中的模块与module函数详解
很快就要开始介绍Lua里的“面向对象”了,在此之前,我们先来了解一下Lua的模块. 1.编写一个简单的模块 Lua的模块是什么东西呢?通常我们可以理解为是一个table,这个table里有一些变量.一 ...
- 【angularJS】定义模块angular.module
模块定义了一个应用程序.控制器通常属于一个模块. JavaScript 中应避免使用全局函数.因为他们很容易被其他脚本文件覆盖. AngularJS 模块让所有函数的作用域在该模块下,避免了该问题. ...
随机推荐
- Revit二次开发示例:ChangesMonitor
在本示例中,程序监控Revit打开文件事件,并在创建的窗体中更新文件信息. #region Namespaces using System; using System.Collections.Ge ...
- XShell通过中转服务器直接连接目标服务器
最近由于公司生产环境的变化,使得我们不能使用自己的机器连接到生产环境去,而是要通过跳板机中转才可以连接.于是今天尝试使用 XShell 通过跳板机直接转接到生产环境. 一.使用代理方式 首先填写连接信 ...
- Hibernate之Hibernate环境搭建
Hibernate之Hibernate环境搭建 一.Hibernate环境搭建的步骤 1.添加Hibernate && SQLServer 的Jar antlr-2.7.7.jar d ...
- AFNetworking源码品读
AFNetworking源码品读 AFNetworking这个库几乎是所有苹果开发人员在使用HTTP协议的第一选择,为什么这个库会有这么大的吸引力呢?其实答案就需要问问自己,为什么会用它,而不是别的库 ...
- 【漏洞预警】Apache ActiveMQ Fileserver远程代码执行漏洞(CVE-2016-3088)
漏洞编码:CVE-2016-3088 实验环境:Linux Apache ActiveMQ版本号:Apache ActiveMQ 5.7.0 ----------------------------- ...
- PHP 操作MySQL时mysql_connect( )和Mysqli( )的两种报错机制
刚开始使用PHP连接MySQL数据库的时候,如果数据库连接不成功或者,对MySQL数据库进行增删改查等操作的时候,SQL语句存在错误,而在执行PHP文件的时候,浏览器并不会抛出错误的原因,一般是空白显 ...
- 【失踪人口回归】第11届东北地区大学生程序设计竞赛——Time to make some change
对哈尔滨出租车和纸质题目和2148473647的吐槽都被毕克神牛在知乎上(https://www.zhihu.com/question/59782275/answer/169402588)pick/b ...
- 【51nod-1239&1244】欧拉函数之和&莫比乌斯函数之和 杜教筛
题目链接: 1239:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1239 1244:http://www.51nod. ...
- TeamViewer运行在Windows Server 2008下连接时错误提示:正在初始化显示参数
这个是使用远程桌面安装和使用Teamviewer的问题,解决方法: 实际上安装完成后TeamViewer有两个ID,一个是个人ID(就是上面卡住的780 567 914),另一个是服务器ID,我们通过 ...
- Win8开机直接进桌面方法
最新的Win8系统由于新增开始屏幕(UI)界面,专门为触摸设备准备,并且很多喜欢尝鲜的电脑爱好者朋友在我们传统的电脑上安装了Win8系统,不少PC用户开始都不喜欢Win8开机后进入UI界面而非传统的电 ...