Skip to main content

Angular Architecture

 

Angular Architecture:

Angular is a platform and framework to build single-page client applications using HTML and TypeScript. It is written in Typescript.

   The basic building blocks are NgModules. It provides compilation context to components. An angular app has always a root module to enable bootstrapping.

overview

                                                              Architectural diagram src: Angular.io

 

The main building blocks of Angular applications:

  1.              Modules 
  2.             Component
  3.             Metadata
  4.             Templates
  5.             Directives 
  6.             Data binding
  7.             Services
  8.             Dependency injection


Modules:

Angular applications are modular and every Angular app has a root module, which provides the bootstrap mechanism. 

    • An angular module is a class with an @NgModule decorator.
    • NgModules import the functionalities form other NgModules just like other JavaScript modules.
    • We can divide the functionality by making several modules. By making this it allows the reusability of code.

 

Components:

The component is the basic building block of Angular application. Every Angular app has at least 1 component known as the root component that connects a component hierarchy with the page document object model (DOM)

Command to create a Component by using Terminal:

  ng g component componentName

When you creating a component it will create the following files. 

Component.ts –  here, we can define the module, properties, data logics.

Component.html -  HTML file where you can see the view.

Component.scss - CSS file for the new component is created.

Component.spec.ts – testing file to perform unit testing

 

A component is defined using the @Component decorator. Under the  @Component decorator, you can define the following items.

Component  selector  - 'app-root',

Component template(HTML  File) -'./app.component.html'

Style for the component -'./app.component.scss'

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'AngularConcepts';
}



Comments

Popular posts from this blog

Observable, Subject , Behavior Subject using RxJS:

  Create an Observable using RxJS:   Import the Observable                                    import  {  Observable  }  from   'rxjs' ; The Observable execution deliver three types of values: "Next" - sends a value such as a Number, a String, an Object, etc. "Error - sends the Error or exception. "Complete" - does not send a value after the Complete                                             ngOnInit ():  void  {                    this . observable$  =  new   Observable ( subscriber   =>  {             ...

What is RxJS?

  What is RxJS? The full form of RxJS is  Reactive Extension for Javascript . As per the official website of RxJS - RxJS is a library for composing asynchronous and event-based programs by using observable sequences . It provides one core type, the  Observable , satellite types (Observer, Schedulers, Subjects) and operators inspired by   Array#extras  (map, filter, reduce, every, etc) to allow handling asynchronous events as collections To manage the sequence of events RxJS combines the Observer pattern with the  Iterator pattern  and functional programming with collections   Observer Pattern: It is a software design pattern in which an object called Subject maintains a list of its dependents called Observers. It works well for applications that expect real-time updates. It is one to many patterns which are one Subject Many Observers. When the subject is updated it will automatically fire an event and notify the observers of the ...

Async-await method - Angular

async   asyncAwait () {    const   c1  =  await   this . c1 ();    const   c2  =  await   this . c2 ();    const   c3  =  await   this . c3 (); } c1 () {    console . log ( 'c1 called' );    return ; } c2 () {    console . log ( 'c2 called' );    return ; } c3 () {    console . log ( 'c3 called' );    return ; } } Output: