@NgModule - is this new?

I am learning angular 2 through the book I just bought (become a ninja with angular 2).

I also look through the official document in parallel, but when you make a quick start from the official site, I see what they are talking about @NgModule, although this is not mentioned in the book.

So, I would like to know if the white paper is up to date, and whether NgModule is really a new thing. It seems that I read somewhere that the document was not up to date, so I would not want to use something that will soon become obsolete.

Here's how they load the application into a book:

import { bootstrap } from '@angular/platform-browser-dynamic';
import PonyRacerAppComponent  from './app/ponyracer-app.component';

bootstrap(PonyRacerAppComponent).catch(err => console.log(err)); 

And this is how they download the app in the official quick launch:

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 { }

then in another file:

// The browser platform with a compiler
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

// The app module
import { AppModule } from './app.module';

// Compile and launch the module
platformBrowserDynamic().bootstrapModule(AppModule);
+4
source share
3 answers

@NgModule is this new? => Yes

angular2 rc5, , , angular 1.x

- .

angular (, FormsModule, HttpModule, RouterModule). angular (, Material Design, Ionic, AngularFire2).

Angular , , , - , .

. , . , angular Http.

. .

+2

Yes, this is a new and well integrated into the final stable release of Angular 2.

This is very well explained in the article by Jecelyn Yeen at - https://scotch.io/bar-talk/getting-to-know-angular-2s-module-ngmodule#module-in-angular-2

Angular 2 module

Go to Angular 2. Angular The module is now called @NgModule.

Question 1 Why do we need @NgModule?

0
source

Source: https://habr.com/ru/post/1651451/


All Articles