- 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.
- PWA入門與實(shí)踐
- Java入門經(jīng)典(第6版)
- JavaScript+jQuery開發(fā)實(shí)戰(zhàn)
- Mastering OpenCV 4
- Python王者歸來
- HTML5+CSS3+JavaScript Web開發(fā)案例教程(在線實(shí)訓(xùn)版)
- 零基礎(chǔ)學(xué)Python網(wǎng)絡(luò)爬蟲案例實(shí)戰(zhàn)全流程詳解(入門與提高篇)
- Android Wear Projects
- Web前端應(yīng)用開發(fā)技術(shù)
- Clojure for Java Developers
- Distributed Computing in Java 9
- Instant jQuery Boilerplate for Plugins
- Mastering HTML5 Forms
- Exploring SE for Android
- Android編程權(quán)威指南(第4版)