Building Universal Applications with
Angular 2
Minko Gechev
github.com/mgechev
twitter.com/mgechev
blog.mgechev.com
github.com/mgechev
twitter.com/mgechev
blog.mgechev.com
Agenda
What is Angular?
What’s wrong with Angular 2?
Introduction to Angular 2
Why Angular 2 is awesome?
Should I use Angular 2 in my next project?
Agenda
What is Angular 2?
What’s wrong with Angular 2?
What are the core concepts of Angular 2?
Why Angular 2 is awesome?
Should I use Angular 2 in my next project?
Agenda
What is Angular 2?
What’s wrong with Angular 2?
What are the core concepts of Angular 2?
Why Angular 2 is awesome?
Should I use Angular 2 in my next project?
Agenda
What is Angular 2?
What’s wrong with Angular 2?
What are the core concepts of Angular 2?
Why Angular 2 is awesome?
Should I use Angular 2 in my next project?
Agenda
What is Angular 2?
What’s wrong with Angular 2?
What are the core concepts of Angular 2?
Why Angular 2 is awesome?
Should I use Angular 2 in my next project?
Agenda
What is Angular 2?
What’s wrong with Angular 2?
What are the core concepts of Angular 2?
Why Angular 2 is awesome?
Should I use Angular 2 in my next project?
What is Angular 2?
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Core concepts of Angular 2
• Directives
• Components
• Pipes
• Services
• Dependency Injection
Directives
Primitive used for encapsulation of
basic UI related logic
tooltip.ts
@Directive({
selector: '[tooltip]',
inputs: ['tooltip'],
host: {
'(mouseenter)': 'onMouseEnter()',
'(mouseleave)': 'onMouseLeave()'
}
})
export class Tooltip {
private overlay:Overlay;
private tooltip:string;
constructor(private el:ElementRef, manager: OverlayManager) {
this.el = el;
this.overlay = manager.get();
}
onMouseEnter() {
this.overlay.open(this.el, this.tooltip);
}
onMouseLeave() {
this.overlay.close();
}
}
tooltip.ts
@Directive({
selector: '[tooltip]',
inputs: ['tooltip'],
host: {
'(mouseenter)': 'onMouseEnter()',
'(mouseleave)': 'onMouseLeave()'
}
})
export class Tooltip {
private overlay:Overlay;
private tooltip:string;
constructor(private el:ElementRef, manager: OverlayManager) {
this.el = el;
this.overlay = manager.get();
}
onMouseEnter() {
this.overlay.open(this.el, this.tooltip);
}
onMouseLeave() {
this.overlay.close();
}
}
tooltip.ts
@Directive({
selector: '[tooltip]',
inputs: ['tooltip'],
host: {
'(mouseenter)': 'onMouseEnter()',
'(mouseleave)': 'onMouseLeave()'
}
})
export class Tooltip {
private overlay:Overlay;
private tooltip:string;
constructor(private el:ElementRef, manager: OverlayManager) {
this.el = el;
this.overlay = manager.get();
}
onMouseEnter() {
this.overlay.open(this.el, this.tooltip);
}
onMouseLeave() {
this.overlay.close();
}
}
What a minute…
this looks like Java
Angular 2 is written in
TypeScript
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
TypeScript is…
superset of ECMAScript
optional type
checking
open source
Building Universal Applications with Angular 2
…you can still use ES5…
tooltip.js
var Tooltip = ng.Directive({
selector: '[tooltip]',
inputs: ['tooltip'],
host: {
'(mouseenter)': 'onMouseEnter()',
'(mouseleave)': 'onMouseLeave()'
}
})
.Class({
constructor: [ng.Inject(ng.ElementRef),
ng.Inject(OverlayManager),
function (tooltip, el, manager) {
this.el = el;
this.overlay = manager.get(tooltip);
}],
onMouseEnter() {
this.overlay.open(this.el, this.tooltip);
},
onMouseLeave() {
this.overlay.close();
}
});
tooltip.js
var Tooltip = ng.Directive({
selector: '[tooltip]',
inputs: ['tooltip'],
host: {
'(mouseenter)': 'onMouseEnter()',
'(mouseleave)': 'onMouseLeave()'
}
})
.Class({
constructor: [ng.Inject(ng.ElementRef),
ng.Inject(OverlayManager),
function (tooltip, el, manager) {
this.el = el;
this.overlay = manager.get(tooltip);
}],
onMouseEnter() {
this.overlay.open(this.el, this.tooltip);
},
onMouseLeave() {
this.overlay.close();
}
});
tooltip.js
var Tooltip = ng.Directive({
selector: '[tooltip]',
inputs: ['tooltip'],
host: {
'(mouseenter)': 'onMouseEnter()',
'(mouseleave)': 'onMouseLeave()'
}
})
.Class({
constructor: [ng.Inject(ng.ElementRef),
ng.Inject(OverlayManager),
function (tooltip, el, manager) {
this.el = el;
this.overlay = manager.get(tooltip);
}],
onMouseEnter() {
this.overlay.open(this.el, this.tooltip);
},
onMouseLeave() {
this.overlay.close();
}
});
Components
Directives with views
hello-world.ts
@Component({
selector: 'hello-world'
})
@View({
template: '<h1>Hello, {{this.target}}!</h1>'
})
class HelloWorld {
target:string;
constructor() {
this.target = 'world';
}
}
hello-world.ts
@Component({
selector: 'hello-world'
})
@View({
template: '<h1>Hello, {{this.target}}!</h1>'
})
class HelloWorld {
target:string;
constructor() {
this.target = 'world';
}
}
hello-world.ts
@Component({
selector: 'hello-world'
})
@View({
template: '<h1>Hello, {{this.target}}!</h1>'
})
class HelloWorld {
target:string;
constructor() {
this.target = 'world';
}
}
Pipes
Encapsulate the
data transformation logic
lowercase-pipe.ts
@Pipe({
name: 'lowercase'
})
class LowerCasePipe implements PipeTransform {
transform(value: string): string {
if (!value) return value;
if (typeof value !== 'string') {
throw new Error('Invalid pipe value', value);
}
return value.toLowerCase();
}
}
Services
Simply, ES2015 classes which can
be wired together with…
Dependency Injection
di.ts
import { provide, Injector, Injectable }
from 'angular2/angular2';
@Injectable()
class DataMapper {
constructor(private http: Http) {}
}
class Http {}
let injector = Injector.resolveAndCreate([
provide(Http).toValue(new Http()),
DataMapper
]);
injector.get(DataMapper);
di.ts
import { provide, Injector, Injectable }
from 'angular2/angular2';
@Injectable()
class DataMapper {
constructor(private http: Http) {}
}
class Http {}
let injector = Injector.resolveAndCreate([
provide(Http).toValue(new Http()),
DataMapper
]);
injector.get(DataMapper);
di.ts
import { provide, Injector, Injectable }
from 'angular2/angular2';
@Injectable()
class DataMapper {
constructor(private http: Http) {}
}
class Http {}
let injector = Injector.resolveAndCreate([
provide(Http).toValue(new Http()),
DataMapper
]);
injector.get(DataMapper);
di.ts
import { provide, Injector, Injectable }
from 'angular2/angular2';
@Injectable()
class DataMapper {
constructor(private http: Http) {}
}
class Http {}
let injector = Injector.resolveAndCreate([
provide(Http).toValue(new Http()),
DataMapper
]);
injector.get(DataMapper);
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Now you know the basics!
Lets take a step back…
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Angular 2 is platform agnostic
Not coupled with DOM, even HTML
Building Universal Applications with Angular 2
…and even more…
Client Server
Client Server
Client Server
GET /
GET *
loop
Client Server
GET /
GET *
loop
Running JavaScript
Client Server
GET /
GET *
loop
GET *
loop
Client Server
GET /
GET *
loop
GET *
loop
server-side rendering
Client Server
Client Server
Client Server
GET /
Client Server
GET /
Running JavaScript
Client Server
GET /
GET *
loop
Client Server
GET /
GET *
loop
Running JavaScript
Client Server
GET /
GET *
loop
Building Universal Applications with Angular 2
Change detection can be
run into separate process
Building Universal Applications with Angular 2
so…what’s wrong with
Angular 2?
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Google
Google
Angular 1
Angular 2
Google
Angular 1
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Angular 2 is…
rewritten from scratch
…developed in a
different language
…completely
incompatible API
…brand
new building blocks
Why?
Web have moved forward
Building Universal Applications with Angular 2
WebWorkers
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Learnt lessons
Mutable state
Tangled data-flow
Building Universal Applications with Angular 2
…we will make the
transition process boring…
Building Universal Applications with Angular 2
ngUpgrade
How to migrate to Angular 2?
(2 easy steps)
Step 1
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
A
B C
D E F
Building Universal Applications with Angular 2
Step 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Thank you!
github.com/mgechev
twitter.com/mgechev
blog.mgechev.com

More Related Content

PDF
Angular 2 Crash Course
PDF
Angular 2... so can I use it now??
PDF
Introduction to Angular 2
PDF
Angular 2 - An Introduction
PDF
Migrating to Angular 2
PPTX
Migrating an application from Angular 1 to Angular 2
PDF
The productive developer guide to Angular 2
PDF
The evolution of Angular 2 @ AngularJS Munich Meetup #5
Angular 2 Crash Course
Angular 2... so can I use it now??
Introduction to Angular 2
Angular 2 - An Introduction
Migrating to Angular 2
Migrating an application from Angular 1 to Angular 2
The productive developer guide to Angular 2
The evolution of Angular 2 @ AngularJS Munich Meetup #5

What's hot (20)

PDF
Angular2 with TypeScript
PDF
Angular2 with type script
ODP
Introduction to Angular 2
PDF
Commit University - Exploring Angular 2
PDF
Angular 2 - The Next Framework
PPTX
Introduction to angular 2
PDF
Angular 2 : le réveil de la force
PPTX
Code migration from Angular 1.x to Angular 2.0
PDF
Angular 2 Essential Training
PPTX
Angular 2 - Better or worse
PDF
Angular 2: core concepts
PPTX
Migrating an Application from Angular 1 to Angular 2
PDF
Introduction to Angular for .NET Developers
PDF
Introduction to angular 2
PPTX
Angular 1.x vs 2 - In code level
PDF
Angular 2: What's New?
PDF
Angular2 workshop
PPTX
AngularJS2 / TypeScript / CLI
PPTX
Angular1x and Angular 2 for Beginners
PDF
Adventures with Angular 2
Angular2 with TypeScript
Angular2 with type script
Introduction to Angular 2
Commit University - Exploring Angular 2
Angular 2 - The Next Framework
Introduction to angular 2
Angular 2 : le réveil de la force
Code migration from Angular 1.x to Angular 2.0
Angular 2 Essential Training
Angular 2 - Better or worse
Angular 2: core concepts
Migrating an Application from Angular 1 to Angular 2
Introduction to Angular for .NET Developers
Introduction to angular 2
Angular 1.x vs 2 - In code level
Angular 2: What's New?
Angular2 workshop
AngularJS2 / TypeScript / CLI
Angular1x and Angular 2 for Beginners
Adventures with Angular 2

Viewers also liked (8)

PDF
Angular 2 - Core Concepts
PDF
Getting Started with Angular 2
PDF
Tech Webinar: Angular 2, Introduction to a new framework
PPTX
Introduction to Angularjs
PPTX
Angular vs. React
PDF
Angular Seminar [한빛미디어 리얼타임 세미나]
PDF
Introduction à Angular 2
PDF
Angular Extreme Performance
Angular 2 - Core Concepts
Getting Started with Angular 2
Tech Webinar: Angular 2, Introduction to a new framework
Introduction to Angularjs
Angular vs. React
Angular Seminar [한빛미디어 리얼타임 세미나]
Introduction à Angular 2
Angular Extreme Performance

Similar to Building Universal Applications with Angular 2 (20)

PDF
Angular 2.0
PDF
Technozaure - Angular2
PDF
Angular 2.0: Brighter future?
PDF
ChtiJUG - Introduction à Angular2
PPTX
Introduction to Angular2
PDF
Sharper Better Faster Dagger ‡ - Droidcon SF
PDF
From Legacy to Hexagonal (An Unexpected Android Journey)
PPTX
2. Design patterns. part #2
PPTX
Angular 2 Migration - JHipster Meetup 6
PDF
Ngrx meta reducers
PDF
Workshop 13: AngularJS Parte II
PDF
Architecture for scalable Angular applications (with introduction and extende...
PDF
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
PDF
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
PDF
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
PDF
Building maintainable app #droidconzg
PDF
Daggerate your code - Write your own annotation processor
PDF
Djangocon 2014 angular + django
PDF
Building maintainable app
ODP
Qt Workshop
Angular 2.0
Technozaure - Angular2
Angular 2.0: Brighter future?
ChtiJUG - Introduction à Angular2
Introduction to Angular2
Sharper Better Faster Dagger ‡ - Droidcon SF
From Legacy to Hexagonal (An Unexpected Android Journey)
2. Design patterns. part #2
Angular 2 Migration - JHipster Meetup 6
Ngrx meta reducers
Workshop 13: AngularJS Parte II
Architecture for scalable Angular applications (with introduction and extende...
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Building maintainable app #droidconzg
Daggerate your code - Write your own annotation processor
Djangocon 2014 angular + django
Building maintainable app
Qt Workshop

Recently uploaded (20)

PDF
State of AI in Business 2025 - MIT NANDA
PDF
NewMind AI Journal Monthly Chronicles - August 2025
PDF
Human Computer Interaction Miterm Lesson
PDF
Applying Agentic AI in Enterprise Automation
PPTX
Information-Technology-in-Human-Society (2).pptx
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
PDF
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
Intravenous drug administration application for pediatric patients via augmen...
PDF
Altius execution marketplace concept.pdf
PDF
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
PDF
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
PDF
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
PDF
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
PPTX
Information-Technology-in-Human-Society.pptx
PDF
Child-friendly e-learning for artificial intelligence education in Indonesia:...
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PDF
Addressing the challenges of harmonizing law and artificial intelligence tech...
PPTX
maintenance powerrpoint for adaprive and preventive
State of AI in Business 2025 - MIT NANDA
NewMind AI Journal Monthly Chronicles - August 2025
Human Computer Interaction Miterm Lesson
Applying Agentic AI in Enterprise Automation
Information-Technology-in-Human-Society (2).pptx
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
Intravenous drug administration application for pediatric patients via augmen...
Altius execution marketplace concept.pdf
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
Information-Technology-in-Human-Society.pptx
Child-friendly e-learning for artificial intelligence education in Indonesia:...
Ebook - The Future of AI A Comprehensive Guide.pdf
Addressing the challenges of harmonizing law and artificial intelligence tech...
maintenance powerrpoint for adaprive and preventive

Building Universal Applications with Angular 2