- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 260字
- 2021-07-15 17:05:28
NgModules
Angular framework has various libraries that are grouped as modules in order to build an application. Angular applications are modular in nature and are constructed by assembling various modules. Modules may have components, services, functions, and/or values. Some modules may have a collection of other modules and are known as library modules.
Angular packages, such as core, common, http, and router that are prefixed with @angular comprise many modules. We import what our application needs from these library modules as follows:
import {Http, Response} from @angular/http';
Here, we import Http and Response from the library module, @angular/http. @angular/http refers to a folder in the Angular package. Any module defined to be exported can be imported into another module by referring to the filename of the module.
However, we can also refer to the folder as we referred to @angular/http. This can be achieved by adding an index.ts file to the folder and adding the code to export modules from the folder. This is a best practice suggested by Angular's style guide and is called the barrel technique:
export * from './http';
This is the export statement in the index.ts found in @angular/http. The statement means that it exports all the modules in HTTP and that they can be imported to our application wherever needed.
When we write an Angular application, we start by defining an AppComponent (not necessarily with the same name) and exporting it.
- GAE編程指南
- Deploying Node.js
- 國際大學生程序設計競賽中山大學內部選拔真題解(二)
- R語言數據分析從入門到精通
- Learning RxJava
- Java從入門到精通(第4版)
- Hadoop+Spark大數據分析實戰
- Scratch 3游戲與人工智能編程完全自學教程
- Python算法從菜鳥到達人
- ANSYS Fluent 二次開發指南
- 深度學習原理與PyTorch實戰(第2版)
- Buildbox 2.x Game Development
- SQL Server 入門很輕松(微課超值版)
- HTML+CSS+JavaScript網頁制作:從入門到精通(第4版)
- Magento 2 Beginners Guide