YogeshChauhan . com

Introduction to Angular modules Part 2: NgModules and components

in Angular on May 9, 2020

If you haven't read it yet, here is the Part 1 Link:

Introduction To Angular Modules Part 1: NgModule Metadata

Introduction to Angular modules: Part 2

NgModules and components

NgModules provide a compilation context for their components.

A root NgModule always has a root component that is created during bootstrap.

Any NgModule can include any number of additional components, which can be loaded through the router or created through the template.

The components that belong to an NgModule share a compilation context.

A component and its template
A component and its template

A component and its template together define a view.

A component can contain a view hierarchy, which allows you to define arbitrarily complex areas of the screen that can be created, modified, and destroyed as a unit.

A view hierarchy can mix views defined in components that belong to different NgModules. This is often the case, especially for UI libraries.

A view hierarchy
A view hierarchy

When you create a component, it's associated directly with a single view, called the host view.

The host view can be the root of a view hierarchy, which can contain embedded views, which are in turn the host views of other components.

Those components can be in the same NgModule, or can be imported from other NgModules.

Views in the tree can be nested to any depth.

Note: The hierarchical structure of views is a key factor in the way Angular detects and responds to changes in the DOM and app data.

Next

Introduction To Angular Modules Part 3: NgModules Vs JavaScript Modules And Angular Libraries

Credit: Angular.io

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

For Each Loop in Swift for BeginnersSwiftSequence generator (range) using JavaScript Array.from()JavaScriptFew more :nth-child examples in CSSCSSHow Do You Make a Private VPN?MiscImplicit and Explicit Joins in Oracle SQLSQL/MySQLWordPress: How to find all posts with a specific custom field value?WordPress