Angular2(八)--module化(核心模块与共享模块)
来源:互联网 发布:sql中删除重复数据 编辑:程序博客网 时间:2024/05/17 21:46
Ahead-Of-time (AoT)
在main.ts可以设置AppModuleNgFactory(The app module factory produced by the static offline compiler)
(main.ts)// The app module factory produced by the static offline compilerimport { AppModuleNgFactory } from './app.module.ngfactory';// Launch with the app module factory.platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
使用@input input binding是在标签后使用[name]来关联,而name相当于一个变量,我们需要为它赋值
Modules are a great way to provide services for all of the module’s components.
NgModel belongs to Angular’s FormsModule
NgModule belongs to Angular’s coreWhen the two directives compete to color the same element, the directive declared
later wins because its DOM changes overwrite the first.The root module and the feature module share the same execution context. They share
the same dependency injector which means the services in one module are available to all.Modules do not inherit access to the components, directives or pipes that are declared
in other modules.service instances, they rely on Angular dependency injection to do this kind of sharing, not the module system.Do not specify app-wide singleton providers in a shared module. A lazy loaded module that imports that shared module will make its own copy of the service.
shared module for shared component,directive,pips
core module for a single CoreModule that we import once when the app starts and never import anywhere else.The moduleId: module.id property sets the base for module-relative loading of the templateUrl.
core module示例
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';import { CommonModule } from '@angular/common';import { TitleComponent } from './title.component';import { UserService } from './user.service';@NgModule({ imports: [ CommonModule ], declarations: [ TitleComponent ], exports: [ TitleComponent ], providers: [ UserService ]})export class CoreModule {}
shared module 示例:
import { NgModule } from '@angular/core';import { CommonModule } from '@angular/common';import { FormsModule } from '@angular/forms';import { AwesomePipe } from './awesome.pipe';import { HighlightDirective } from './highlight.directive';@NgModule({ imports: [ CommonModule ], declarations: [ AwesomePipe, HighlightDirective ], exports: [ AwesomePipe, HighlightDirective, CommonModule, FormsModule ]})export class SharedModule { }
- Angular2(八)--module化(核心模块与共享模块)
- angular2模块和共享模块
- ES6详解八:模块(Module)!
- Angular2(一)--模块
- OpenCV学习笔记2 OpenCV核心模块与核心功能Core Module & Core Functionality(一)
- OpenCV学习笔记3 OpenCV核心模块与核心功能Core Module & Core Functionality(二)
- OpenCV学习笔记4 OpenCV核心模块与核心功能Core Module & Core Functionality(三)
- OpenCV学习笔记5 OpenCV核心模块与核心功能Core Module & Core Functionality(四)
- OpenCV学习笔记6 OpenCV核心模块与核心功能Core Module & Core Functionality(五)
- OpenCV学习笔记7 OpenCV核心模块与核心功能Core Module & Core Functionality(六)
- Angular2笔记(四)--模块
- linux核心与核心模块
- Node.JS核心模块之module分析
- Python模块(Module)
- Angular2入门之模块与组件
- Python(八) 模块与包
- Module模块
- angular2模块划分总结
- C#制作gif
- 数据结构(二)线性表
- python数据结构学习笔记-2016-12-04-02-二叉搜索树
- DBH
- 集合
- Angular2(八)--module化(核心模块与共享模块)
- nexus私服安装配置
- iOS开发之RunLoop-赵鹏举
- 04-树7 二叉搜索树的操作集
- 一个菜鸟的QT学习笔记(1)
- 【STM8L】STM8L之内部16M晶振
- Linux环境C语言编译与头文件等知识点小结
- 简单的通讯录——第一版
- 数据结构实验之查找七:线性之哈希表(线性探测解决哈希表的冲突)