Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between angular 2 modules and Javascript ES6 modules

Angular 2 modules allow apps to be divided into multiple modules, each serving a different purpose.

But isn't that what ES6 modules also supposed to do? What is the difference between the two?

like image 600
kayasa Avatar asked Feb 17 '17 12:02

kayasa


People also ask

What is the difference between Angular module and JavaScript module?

What is the difference between Javascript Module & Angular Module ? The difference between Js Module & Angular Module is Js module is just a file, but angular module is a class that logically groups the components and others.

What are Angular 2 modules?

Modules are used in Angular JS to put logical boundaries in your application. Hence, instead of coding everything into one application, you can instead build everything into separate modules to separate the functionality of your application.

What is JavaScript ES6 modules?

Modules are the piece or chunk of a JavaScript code written in a file. JavaScript modules help us to modularize the code simply by partitioning the entire code into modules that can be imported from anywhere. Modules make it easy to maintain the code, debug the code, and reuse the piece of code.

Does Angular use ES6?

Angular makes use of a number of features of ES6 and TypeScript.


1 Answers

Taken from angular.io:

The Angular module classes differ from JavaScript module class in three key respects:

  1. An Angular module bounds declarable classes only. Declarables are the only classes that matter to the Angular.

  2. Instead of defining all member classes in one giant file (as in a JavaScript module), we list the module's classes in the @NgModule.declarations list.

  3. An Angular module can only export the declarable classes it owns or imports from other modules. It doesn't declare or export any other kind of class.
like image 54
Haseoh Avatar answered Oct 21 '22 08:10

Haseoh