SlideShare a Scribd company logo
Meetup: AngularJS-Bucharest (25-10-2016)
Angular 2 Architecture (Bucharest 26/10/2016)
System
shim
ZoneReflectRx
Libraries
Application
core & common
Angular Frameworks
Router UpgradeHttp Compiler PlatformFormsRouter
<todo-list [source]="todos"
(selected-change)="update($event)" />
System
shim
ZoneReflectRx
Libraries
Application
core & common
Angular Frameworks
Router UpgradeHttp Compiler PlatformFormsRouter
Angular 2 Architecture (Bucharest 26/10/2016)
<h1> Hi {{name}} </h1>
<div [property]="value" ></div>
<div (click)="setActive(todo)" ></div>
<input type="text" [(ngModel)]="todo.done">
One-way (Input):
One-way (Output):
Two-way:
DD
D
D
D D
D
D
D
D
D
D
D
<div *ngFor="let todo of todos" >
<input type="checkbox" [(ngModel)]="todo.done" >
<span (click)="setActive(todo)"
[class.done]="todo.done" >
{{todo.text}}
</span>
</div>
@Component({
selector: 'todo-list',
template: `
<div *ngFor="let todo of todos">
<input type="checkbox" [(ngModel)]="todo.done">
<span (click)="setActive(todo)"
[class.done]="todo.done">
{{todo.text}}
</span>
</div>
`})
export class TodoList {
@Output() selectedChange = new EventEmitter()
@Input('source') todos: Todo[] = [];
constructor(private db:Db, private proxy:Proxy){}
}
@Component({
selector: 'todo-list',
template: `
<div *ngFor="let todo of todos">
<input type="checkbox" [(ngModel)]="todo.done">
<span (click)="setActive(todo)"
[class.done]="todo.done">
{{todo.text}}
</span>
</div>
`})
export class TodoList {
@Output() selectedChange = new EventEmitter()
@Input('source') todos: Todo[] = [];
constructor(private db:Db, private proxy:Proxy){}
}
<todo-list [source]="todos"
(selected-change)="update($event)" />
Angular 2 Architecture (Bucharest 26/10/2016)
@Injectable()
class Engine {}
@Injectable()
class Car {
constructor( public engine : Engine ) {}
}
var injector = Injector.resolveAndCreate([ Car , Engine ] );
var car = injector.get(Car);
A
Parent Injector
A,B,C
Child Injector
A,B
Child Injector
A
B C
@Injectable()
class A{
constructor(b:B,c:C){ //... }
}
Platform Injectors
Component Injectors
Application Injectors
@Component({
selector: 'todo-list',
providers : [UserProxy],
template: `...`})
export class TodoListComponent { }
@NgModule({
declarations:[AppComponent, ... ],
providers :[UserProxy],
bootstrap :[AppComponent],
imports :[...]
})
export class AppModule{}
platformBrowserDynamic()
.bootstrapModule(AppModule);
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
FormsModule
exports
(NgModel…)
CommonModule
exports
( NgIf , … )
My Components,
Directives & Pipes
Template Context@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...]
})
export class XxxModule{}
@NgModule({
})
export class XxxModule{}
Application Injector
XxxModule
providers
RouterModule
providers
Lazy Loading
Boundary
Module Injector
MathModule
providers
UsersModule
providers
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...],
providers :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...],
providers :[...]
})
export class XxxModule{}
@NgModule({
declarations:[...],
imports :[...],
exports :[...],
bootstrap :[...],
providers :[...]
})
export class XxxModule{}
Platform
Injector
Lazy Loading
Boundary
App Module
Core
Module
Feature I
Module
Feature II
Module
Feature III
Module
Shared
Module
Shared
Module
Lazy Loading
Boundary
App Module
Core
Module
Feature I
Module
Feature II
Module
Feature III
Module
Shared
Module
Shared
Module
Lazy Loading
Boundary
App Module
Core
Module
Feature I
Module
Feature II
Module
Feature III
Module
Shared
Module
Shared
Module
@NgModule({
imports: [...],
declarations: [...],
exports: [...],
providers: [...]
})
export class CoreModule {
constructor (@Optional() @SkipSelf() parentModule: CoreModule) {
if (parentModule) {
throw new Error('CoreModule is already loaded.');
}
}
static forRoot(config: UserServiceConfig): ModuleWithProviders {
return {
ngModule: CoreModule,
providers: [
{provide: UserServiceConfig, useValue: config }
]
};
}
}
Prevent
reimport
Configure
core services
Angular 2 Architecture (Bucharest 26/10/2016)
UI
(DOM)
Model
<div *ngFor="#todo of todos">
<input [(ngModel)]="todo.done">
<span (click)="setActive(todo)"
[class.done]="todo.done">
{{todo.text}}
</span>
</div>
Component
(7 expressions)
Component
(5 expressions)
Component
(9 expressions)
Component
(6 expressions)
Component
(2 expressions)
Component
(3 expressions)
 {{interpolation}}
 [property] = "exp"
Timer Event
(50ms)
Communication (300ms)
UI Events
(avg 3s)
UI Events
(avg 2s)
Component
(7 expressions)
Component
(5 expressions)
Component
(9 expressions)
Component
(6 expressions)
Component
(2 expressions)
Component
(3 expressions)
Angular 2 Architecture (Bucharest 26/10/2016)
export class CounterComponent {
value:number = 0;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
setInterval( ()=>{ this.value++; } , 50 );
}
}
Ticks
Never use
setInterval method
setInterval( ()=>{ this.value++; } , 50 );
Update
export class CounterComponent {
value:number = 0;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
run();
}
run(){
this.value++;
setTimeout( ()=> { this.run() } , 50 );
}
}
Create method
every time
Ticks Update
setTimeout( ()=> { this.run() } , 50 );
export class CounterComponent {
value : number = 0;
runFnBind : any;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
this.runFnBind = this.run.bind(this);
run();
}
run(){
this.value++;
setTimeout( this.runFnBind , 50 );
}
}
Ticks Update
this.runFnBind = this.run.bind(this);
setTimeout( this.runFnBind , 50 );
export class CounterComponent {
value : number = 0;
runFnBind : any;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
this.runFnBind = this.run.bind(this);
zone.runOutsideAngular( this.runFnBind );
}
run(){
this.value++;
setTimeout( this.runFnBind , 50 );
}
}
Ticks Update
zone.runOutsideAngular( this.runFnBind );
export class CounterComponent {
value:number = 0;
constructor(private zone:NgZone,
private cd :ChangeDetectorRef){
zone.runOutsideAngular( this.run.bind(this) );
}
run(){
this.value++;
this.cd.detectChanges();
setTimeout( this.run.bind(this) , 50 );
}
}
Ticks Update
this.cd.detectChanges();
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Search
Title : {{title}}
Name : {{name}}
Phone : {{phone}}
Mobile : {{mobile}}
Picture: {{picture}}
Angular 2 Architecture (Bucharest 26/10/2016)
export class MonitorComponent {
...
constructor(private cd :ChangeDetectorRef){
cd.detach();
}
...
set serverLoadValue(val){
let isthreshold = this.checkThreshold(val);
this._serverLoadValue = val;
if(isthreshold){
this.cd.detectChanges();
}
}
}
cd.detach();
this.cd.detectChanges();
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)

More Related Content

PPTX
Http Communication in Angular 2.0
PPTX
Angular 2.0 forms
PPTX
Modules and injector
PPTX
Angular 2 - Ahead of-time Compilation
PPTX
Routing And Navigation
PPTX
Performance Optimization In Angular 2
PDF
Databinding and Performance-Tuning in Angular 2
PPTX
Angular 2 NgModule
Http Communication in Angular 2.0
Angular 2.0 forms
Modules and injector
Angular 2 - Ahead of-time Compilation
Routing And Navigation
Performance Optimization In Angular 2
Databinding and Performance-Tuning in Angular 2
Angular 2 NgModule

What's hot (20)

PPTX
Template syntax in Angular 2.0
PPTX
Angular 2.0 Dependency injection
PPTX
Angular 1.x vs. Angular 2.x
PPTX
Upgrading from Angular 1.x to Angular 2.x
PPTX
AngularJS Internal
PPTX
Angular 2.0 Routing and Navigation
PPTX
AngularJS $Provide Service
PPTX
AngularJS Compile Process
PPTX
AngularJs $provide API internals & circular dependency problem.
PPTX
Angular 2.0 Views
PDF
준비하세요 Angular js 2.0
PDF
AngularJS Basics with Example
PDF
Workshop 12: AngularJS Parte I
PPTX
AngularJS Architecture
PDF
AngularJS Framework
PPTX
AngularJs
PPTX
AngularJS Directives
PPTX
The AngularJS way
PPTX
Workshop 1: Good practices in JavaScript
PDF
[FEConf Korea 2017]Angular 컴포넌트 대화법
Template syntax in Angular 2.0
Angular 2.0 Dependency injection
Angular 1.x vs. Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
AngularJS Internal
Angular 2.0 Routing and Navigation
AngularJS $Provide Service
AngularJS Compile Process
AngularJs $provide API internals & circular dependency problem.
Angular 2.0 Views
준비하세요 Angular js 2.0
AngularJS Basics with Example
Workshop 12: AngularJS Parte I
AngularJS Architecture
AngularJS Framework
AngularJs
AngularJS Directives
The AngularJS way
Workshop 1: Good practices in JavaScript
[FEConf Korea 2017]Angular 컴포넌트 대화법
Ad

Similar to Angular 2 Architecture (Bucharest 26/10/2016) (12)

PPTX
Angular 2 Architecture
PDF
Angular2: Quick overview with 2do app example
PDF
Angular2 intro
PPTX
Angular2 + rxjs
PDF
Angular2 with TypeScript
PDF
Angular and The Case for RxJS
PPTX
Reactive Angular 2
PDF
Mattia Manzati - Real-World MobX Project Architecture - Codemotion Rome 2019
PDF
Angular - Chapter 4 - Data and Event Handling
PDF
Data models in Angular 1 & 2
PDF
Mobx - performance and sanity
PDF
What is your money doing?
Angular 2 Architecture
Angular2: Quick overview with 2do app example
Angular2 intro
Angular2 + rxjs
Angular2 with TypeScript
Angular and The Case for RxJS
Reactive Angular 2
Mattia Manzati - Real-World MobX Project Architecture - Codemotion Rome 2019
Angular - Chapter 4 - Data and Event Handling
Data models in Angular 1 & 2
Mobx - performance and sanity
What is your money doing?
Ad

More from Eyal Vardi (15)

PPTX
Why magic
PPTX
Smart Contract
PDF
Rachel's grandmother's recipes
PPTX
Component lifecycle hooks in Angular 2.0
PPTX
Async & Parallel in JavaScript
PPTX
Angular 2.0 Pipes
PPTX
Modules in ECMAScript 6.0
PPTX
Proxies in ECMAScript 6.0
PPTX
Iterators & Generators in ECMAScript 6.0
PPTX
Symbols in ECMAScript 6.0
PPTX
Objects & Classes in ECMAScript 6.0
PPTX
Scope & Functions in ECMAScript 6.0
PPTX
Node.js Spplication Scaling
PPTX
Node.js Socket.IO
PPTX
Node.js Express
Why magic
Smart Contract
Rachel's grandmother's recipes
Component lifecycle hooks in Angular 2.0
Async & Parallel in JavaScript
Angular 2.0 Pipes
Modules in ECMAScript 6.0
Proxies in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0
Symbols in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0
Scope & Functions in ECMAScript 6.0
Node.js Spplication Scaling
Node.js Socket.IO
Node.js Express

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
A Presentation on Artificial Intelligence
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
“AI and Expert System Decision Support & Business Intelligence Systems”
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Electronic commerce courselecture one. Pdf
NewMind AI Monthly Chronicles - July 2025
A Presentation on Artificial Intelligence
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Encapsulation_ Review paper, used for researhc scholars
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...

Angular 2 Architecture (Bucharest 26/10/2016)

Editor's Notes

  • #29: Angular 2 will scan the entire tree component and calculate each expression every 50ms.