+1 vote
in Angular by
Explain app.module.ts file.

1 Answer

0 votes
by

The following code will be present in the app.module.ts file.

import { NgModule }      from '@angular/core'; 

import { BrowserModule } from '@angular/platform-browser';  

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

@NgModule({ 

   imports:      [ BrowserModule ], 

   declarations: [ AppComponent ], 

   bootstrap:    [ AppComponent ] 

}) 

export class AppModule { } 

Let's go through each line of the code in detail.

The import statement is used to import functionality from the existing modules. Thus, the first 3 statements are used to import the NgModule, BrowserModule and AppComponent modules into this module.

The NgModule decorator is used to later on define the imports, declarations, and bootstrapping options.

The BrowserModule is required by default for any web based angular application.

The bootstrap option tells Angular which Component to bootstrap in the application.

Related questions

0 votes
asked Jan 27, 2020 in TypeScript - JavaScript's Superset by AdilsonLima
0 votes
asked Jan 21, 2020 in ECMAScript by GeorgeBell
...