SlideShare a Scribd company logo
Angular 2 Architecture
Angular 2 Architecture
Angular 2 Architecture
Angular 2 Architecture
System
shim
ZoneReflectRx
Libraries
Application
<todo-list [source]="todos"
(selected-change)="update($event)" />
core & common
Angular Frameworks
Router Http Compiler Platform
@Component({
selector: 'todo-list',
styles: [`
.done{
text-decoration: line-through;
color: grey;
}`],
template: `
<ul class="list-unstyled">
<li *ngFor="#todo of todos">
<input type="checkbox" [(ngModel)]="todo.done">
<span [class.done]="todo.done">{{todo.text}}</span>
</li>
</ul>`
})
export class TodoList {
@Output() selectedChange = new EventEmitter()
@Input('source') todos: Todo[] = [];
constructor(private db:Db, private proxy:Proxy){}
}
<div class="container">
<div class="starter-template">
<a href="http://ng-course.org" target="_blank">
<img src="images/ng-course.png" width="500">
</a>
<br>
<my-app>Loading...</my-app>
</div>
</div>
Angular 2 Architecture
<html>
<head>
. . .
<script src="shim.js"></script>
<script src="zone.js"></script>
<script src="Reflect.js"></script>
<script src="system.js"></script>
<script>
System.import('app/main');
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
Async
1
3
2
import {bootstrap} from '@angular/platform-browser-dynamic';
import {AppComponent} from './app.component';
bootstrap(AppComponent);
Load Tree !!!
1
Create Platform
2
Create Application
3
Compile
AppComponent
4
Tick
&
Link (Create Classes)
5
PlatformRef
ApplicationRef
I
I Z C R
IZCR
IC
IC
IC
IC ICIC
// Create Platform Injector
platform(BROWSER_PLATFORM_PROVIDERS)
// Create Application Injector
.application([
BROWSER_APP_PROVIDERS
BROWSER_APP_COMPILER_PROVIDERS,
appProviders
]);
// Create Injector => Compile => tick => Create Classes
.bootstrap( MyApp );
Angular 2 Architecture
A
Parent Injector
A,B,C
Child Injector
A,B
Child Injector
A
B C
@Injectable()
class A{
constructor(b:B,c:C){ //... }
}
Platform
BROWSER_PLATFORM_PROVIDERS
Application
BROWSER_APP_PROVIDERS & CustomProviders
IC
IC
IC
IC ICIC
Component Metadata
 providers
 viewProviders
 directives
 pipes
 PLATFORM_PIPES
 PLATFORM_DIRECTIVES
 FORM_PROVIDERS
 DOCUMENT
 DomRootRenderer
 . . .
 PLATFORM_INITIALIZER
 Reflector
 Console
Component
Metadata
 queries? : {[key: string]: any} Directive
Metadata
import {Component} from "@angular/core";
import {Type1,Type2,Type3} from "eyalVardi";
import {Pipe1,Directive1} from "eyalVardi";
import {Component2} from "eyalVardi";
import {Service1} from "eyalVardi";
@Component({
providers :[Type1,Type2],
viewProviders:[Type3],
pipes :[Pipe1],
directives :[Directive1,Component2]
})
export class MyComponent {
constructor(
element : ElementRef,
type1 : Type1
){}
}
Must solve in
runtime by
the Injector
token
"recipe" for
creating
constructor(token: any, { useClass, useValue, useExisting,
useFactory, deps, multi }: {
useClass? : Type,
useValue? : any,
useExisting?: any,
useFactory? : Function,
deps? : Object[],
multi? : boolean
})
<component my-directive>
<sub-comp/>
<sub-comp/>
</component>
<component my-directive>
<sub-comp/>
<sub-comp/>
</component>
Component3 Template
App
Component1
Component2
Directive1
Component3
loading
<app>Loading</app>
<div>
<component1 directive1="{{name}}">
<component2>
This is content.
</component2>
</component1>
</div>
<div>
<h4>{{name}}</h4>
<ng-content />
</div>
This is
content
<div>
<h4>{{name}}</h4>
<ng-content />
</div>
Component Directive
TemplateContent
viewProviders
directives
pipes
Providers
@ViewChild
@ViewChildren
DOM Element
Providers
Angular 2 Architecture
bootstrap(AppComponent, [
{provide: PLATFORM_DIRECTIVES, useValue: [myComponent], multi:true},
{provide: PLATFORM_PIPES , useValue: [myPipe] , multi:true}
]);
Available in every
component of the
application
Angular 2 Architecture
Angular 2 Architecture
Angular 2 Architecture
@Component({...})
export class MyComponent {
constructor(
element : ElementRef
, changeDetector: ChangeDetectorRef
, viewContainer : ViewContainerRef
, template : TemplateRef
, render : Renderer
){...}
}
Angular 2 Architecture
Component
Metadata
 queries? : {[key: string]: any} Directive
Metadata
templateUrl?
template?
directives?
pipes?
encapsulation?
styles?
styleUrls?
selector?
inputs?
outputs?
host?
providers?
exportAs?
queries?
Angular 2 Architecture
Angular 2 Architecture
Angular 2 Architecture
Angular 2 Architecture
Angular 2 Architecture
IC
IC
IC
IC ICIC
 {{interpolation}}
 [property] = "exp"
 (event) = "exp"
Angular 2 Architecture
IC
IC
IC
IC ICIC
Angular 2 Architecture
Angular 2 Architecture
Component
TemplateContent
Component
TemplateContent
1
2
3
4
5
6
7
Angular 2 Architecture
Angular 2 Architecture

More Related Content

What's hot (20)

PPTX
Angular 2.0 Views
Eyal Vardi
 
PPTX
Modules and injector
Eyal Vardi
 
PPTX
Angular 2.0 forms
Eyal Vardi
 
PPTX
Upgrading from Angular 1.x to Angular 2.x
Eyal Vardi
 
PPTX
Angular 2.0 Pipes
Eyal Vardi
 
PPTX
AngularJS $Provide Service
Eyal Vardi
 
PPTX
AngularJS Compile Process
Eyal Vardi
 
PPTX
Angular 2.0 Dependency injection
Eyal Vardi
 
PPTX
AngularJS - $http & $resource Services
Eyal Vardi
 
PPTX
Angular 2 NgModule
Eyal Vardi
 
PDF
Databinding and Performance-Tuning in Angular 2
Manfred Steyer
 
PPTX
Workshop 1: Good practices in JavaScript
Visual Engineering
 
PPTX
AngularJS Internal
Eyal Vardi
 
PPTX
AngularJS Services
Eyal Vardi
 
PPTX
AngularJs $provide API internals & circular dependency problem.
Yan Yankowski
 
PDF
Workshop 10: ECMAScript 6
Visual Engineering
 
KEY
Symfony2 Building on Alpha / Beta technology
Daniel Knell
 
PDF
Angular promises and http
Alexe Bogdan
 
PPTX
AngularJS Routing
Eyal Vardi
 
PDF
Workshop 12: AngularJS Parte I
Visual Engineering
 
Angular 2.0 Views
Eyal Vardi
 
Modules and injector
Eyal Vardi
 
Angular 2.0 forms
Eyal Vardi
 
Upgrading from Angular 1.x to Angular 2.x
Eyal Vardi
 
Angular 2.0 Pipes
Eyal Vardi
 
AngularJS $Provide Service
Eyal Vardi
 
AngularJS Compile Process
Eyal Vardi
 
Angular 2.0 Dependency injection
Eyal Vardi
 
AngularJS - $http & $resource Services
Eyal Vardi
 
Angular 2 NgModule
Eyal Vardi
 
Databinding and Performance-Tuning in Angular 2
Manfred Steyer
 
Workshop 1: Good practices in JavaScript
Visual Engineering
 
AngularJS Internal
Eyal Vardi
 
AngularJS Services
Eyal Vardi
 
AngularJs $provide API internals & circular dependency problem.
Yan Yankowski
 
Workshop 10: ECMAScript 6
Visual Engineering
 
Symfony2 Building on Alpha / Beta technology
Daniel Knell
 
Angular promises and http
Alexe Bogdan
 
AngularJS Routing
Eyal Vardi
 
Workshop 12: AngularJS Parte I
Visual Engineering
 

More from Eyal Vardi (14)

PPTX
Why magic
Eyal Vardi
 
PPTX
Smart Contract
Eyal Vardi
 
PDF
Rachel's grandmother's recipes
Eyal Vardi
 
PPTX
Angular 2.0 Routing and Navigation
Eyal Vardi
 
PPTX
Async & Parallel in JavaScript
Eyal Vardi
 
PPTX
Modules in ECMAScript 6.0
Eyal Vardi
 
PPTX
Proxies in ECMAScript 6.0
Eyal Vardi
 
PPTX
Iterators & Generators in ECMAScript 6.0
Eyal Vardi
 
PPTX
Symbols in ECMAScript 6.0
Eyal Vardi
 
PPTX
Objects & Classes in ECMAScript 6.0
Eyal Vardi
 
PPTX
Scope & Functions in ECMAScript 6.0
Eyal Vardi
 
PPTX
Node.js Spplication Scaling
Eyal Vardi
 
PPTX
Node.js Socket.IO
Eyal Vardi
 
PPTX
Node.js Express
Eyal Vardi
 
Why magic
Eyal Vardi
 
Smart Contract
Eyal Vardi
 
Rachel's grandmother's recipes
Eyal Vardi
 
Angular 2.0 Routing and Navigation
Eyal Vardi
 
Async & Parallel in JavaScript
Eyal Vardi
 
Modules in ECMAScript 6.0
Eyal Vardi
 
Proxies in ECMAScript 6.0
Eyal Vardi
 
Iterators & Generators in ECMAScript 6.0
Eyal Vardi
 
Symbols in ECMAScript 6.0
Eyal Vardi
 
Objects & Classes in ECMAScript 6.0
Eyal Vardi
 
Scope & Functions in ECMAScript 6.0
Eyal Vardi
 
Node.js Spplication Scaling
Eyal Vardi
 
Node.js Socket.IO
Eyal Vardi
 
Node.js Express
Eyal Vardi
 
Ad

Recently uploaded (20)

PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Ad

Angular 2 Architecture