YogeshChauhan.com
Introduction to Angular modules Part 2: NgModules and components
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

dreamhost

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress? Mar 3 substring() Method in JavaScript Mar 3 Window setInterval() Method in JavaScript Mar 2 How to zoom an element on hover using CSS? Mar 2 the box-sizing property in CSS

You might also like these

How to vertically and horizontally align text and image block (without flex or grid) in CSS?CSSINTERSECT and EXCEPT in PostgresPostgresWhat are Identifiers in JavaScript?JavaScriptSocial Media Colors: Sass VariablesMiscLEFT JOIN in PostgresPostgresHow to Make CSS Lists Bullets Smaller?CSS