Free Time Learning
What is the Angular 8/9/10 Architecture ?

The basic building blocks of an Angular application are NgModules. It collects related code into functional sets. An app always has at least a root module that enables bootstrapping, and typically has many more feature modules. These feature modules contain components.
 i) Components define views, which are sets of screen elements that Angular can choose among and modify according to your program logic and data.
 
 ii) Components use services, which provide specific functionality not directly related to views. Service providers can be injected into components as dependencies, making your code modular, reusable, and efficient.

Modules

Every Angular app has a root module known as AppModule. It provides the bootstrap mechanism that launches the application.
 
However, every application contains many functional modules.
 
Some important features of Angular 10 Modules:
 
 i) Angular NgModules import the functionalities form other NgModules just like other JavaScript modules.
 
 ii) NgModules allow their own functionality to be exported and used by other NgModules. For example, if you want to use the router service in your app, you can import the Router NgModule.

Components

Components and services both are simply classes with decorators that mark their types and provide metadata that guide Angular to do things.
 
Every Angular application always has at least one component known as root component that connects a page hierarchy with page DOM.
 
Each component defines a class that contains feature application data and logic. It is also associated with an HTML template that defines a view i.e. to be displayed on a browser.
Metadata of Component class
 
 i) The metadata for a component class associates it with a template that defines a view. A template combines ordinary HTML with Angular directives and binding markup that allow Angular to modify the HTML before rendering it for display.
 
 ii) The metadata for a service class provides the information Angular needs to make it available to components through dependency injection (DI).

Template, Directives and Data Binding

a template is used to combine HTML with Angular Markup and modify HTML elements before displaying them. Template directives provide program logic, and binding markup connects your application data and the DOM.
 
There are two types of data binding:
 
 1. Event Binding: Event binding is used to bind events to your app and respond to user input in the target environment by updating your application data.

 2. Property Binding: Property binding is used to pass data from component class and facilitates you to interpolate values that are computed from your application data into the HTML.

Services and Dependency Injection

When you create a service class for data or logic that isn’t associated with a specific view, and want to share across components. DI comes into play.
Dependency Injection (DI) is used to make your component classes lean and efficient. DI doesn’t fetch data from the server, validate user input, or log directly to the console; it simply renders such tasks to services.

Routing

Routing (Router) is an NgModule essential part which facilitates coders to define a navigation path among the different application states and view hierarchies in the app. It is similar to the way we navigate on browser:
 
 i) Entering URL in the address bar and the browser will navigate to that page.
 
 ii) Clicking the link on a page and the browser will navigate to a new page.
 
 iii) Clicking the browser’s back or forward buttons and the browser will navigate back or forth according to your seen history pages.
 
The router maps URL-like paths to views instead of pages. If application build in modular fashion, the router can lazy-load the module on demand.
What is the Angular 8/9/10 Architecture ?