Home > Web Front-end > JS Tutorial > body text

Detailed explanation of NgModule (module) in Angular

青灯夜游
Release: 2021-04-19 09:31:52
forward
2042 people have browsed it

This article will take you to learn more about NgModule (module) in Angular. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Detailed explanation of NgModule (module) in Angular

Angular module (NgModule)

  • Angular applications are modular and have their own modular system called NgModule . An NgModule is a container used to store some cohesive code blocks that focus on a certain application area, a certain workflow, or a set of closely related functions. It can contain some components, service providers or other code files, the scope of which is defined by the NgModule that contains them. It can also import some functions exported by other modules, and export some specified functions for use by other NgModules.
  • A module is also a TypeScript class with the @NgModule decorator.

Related tutorial recommendations: "angular tutorial"

NgModule metadata

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {HttpClient, HttpClientModule} from '@angular/common/http';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpClientModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
Copy after login
  • declarations

#Declaring something in a module can only declare components, instructions and pipes.

  • imports

The import table declares some modules that the application depends on to run.

  • providers

Declares which services are provided in the module, only services can be declared.

  • bootstrap

Declares what the main component of the module is. Only the root module should set this bootstrap attribute.

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of Detailed explanation of NgModule (module) in Angular. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!