Skip to main content

Posts

Showing posts with the label Purpose of @NgModule

What are the differences in NgModules and JavaScript Modules?

What are the differences in NgModules and JavaScript Modules? NgModules vs. JavaScript Modules  - The NgModule is a TypeScript class decorated with @NgModule Decorator - is a fundamental feature of Angular. JavaScript also has its own module system for managing collections of JavaScript objects. It is completely different from the NgModule system. In JavaScript, each file is a module and all objects defined in the file belong to that module. The module declares some objects to be public by marking them with the export keyword. Other JavaScript modules use import statements to access public objects from other modules. The following is an example of specifying an export and import statements - export   class   AppComponent  {     //... } After export your class, you can import that file code in another file. import  {  AppComponent  }  from   './app.component' ; Both the JavaScript and An...

What Types of @NgModules?

What Types of NgModules? There are four types of NgModules – 1.            Features Module 2.            Routing Module 3.            Service Module 4.            Widget Module 5.            Shared Module Features Module  – The feature modules are NgModules  for the purpose of organizing an application code. Routing Module  – The Routing is used to manage routes and also enables navigation from one view to another view as users perform application tasks. Service Module  – The modules that only contain services and providers. It provides utility services such as data access and messaging. The root AppModule is the only module that should import service modules. The HttpClientModule  is a good ...

What Are the Purpose of @NgModule?

What Are the Purpose of @NgModule? The NgModule is used to simplify the ways you define and manage the dependencies in your applications and also you can consolidate different components and services into cohesive blocks of functionality. The @NgModule metadata divided into three categories as follows. 1.            Static 2.            Runtime 3.            Composability/Grouping Static  – It is compiler configuration and configured via the declarations array. Runtime  - It is injector configuration and configured via the provider’s array. Composability/Grouping  – Introducing NgModules  together and configured via the imports and exports arrays. The following is an example of specifying a NgModule metadata - @ NgModule ({    // Static, This is the compiler configuration ...