SlideShare a Scribd company logo
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

What's hot (20)

PDF
Angular2 with TypeScript
Rohit Bishnoi
 
PDF
Angular2 with type script
Ravi Mone
 
ODP
Introduction to Angular 2
Knoldus Inc.
 
PDF
Commit University - Exploring Angular 2
Commit University
 
PDF
Angular 2 - The Next Framework
Commit University
 
PPTX
Introduction to angular 2
Dor Moshe
 
PDF
Angular 2 : le réveil de la force
Nicolas PENNEC
 
PPTX
Code migration from Angular 1.x to Angular 2.0
Ran Wahle
 
PDF
Angular 2 Essential Training
Patrick Schroeder
 
PPTX
Angular 2 - Better or worse
Vladimir Georgiev
 
PDF
Angular 2: core concepts
Codemotion
 
PPTX
Migrating an Application from Angular 1 to Angular 2
Ross Dederer
 
PDF
Introduction to Angular for .NET Developers
Laurent Duveau
 
PDF
Introduction to angular 2
Dhyego Fernando
 
PPTX
Angular 1.x vs 2 - In code level
Anuradha Bandara
 
PDF
Angular 2: What's New?
jbandi
 
PDF
Angular2 workshop
Nir Kaufman
 
PPTX
AngularJS2 / TypeScript / CLI
Domenico Rutigliano
 
PPTX
Angular1x and Angular 2 for Beginners
Oswald Campesato
 
PDF
Adventures with Angular 2
Dragos Ionita
 
Angular2 with TypeScript
Rohit Bishnoi
 
Angular2 with type script
Ravi Mone
 
Introduction to Angular 2
Knoldus Inc.
 
Commit University - Exploring Angular 2
Commit University
 
Angular 2 - The Next Framework
Commit University
 
Introduction to angular 2
Dor Moshe
 
Angular 2 : le réveil de la force
Nicolas PENNEC
 
Code migration from Angular 1.x to Angular 2.0
Ran Wahle
 
Angular 2 Essential Training
Patrick Schroeder
 
Angular 2 - Better or worse
Vladimir Georgiev
 
Angular 2: core concepts
Codemotion
 
Migrating an Application from Angular 1 to Angular 2
Ross Dederer
 
Introduction to Angular for .NET Developers
Laurent Duveau
 
Introduction to angular 2
Dhyego Fernando
 
Angular 1.x vs 2 - In code level
Anuradha Bandara
 
Angular 2: What's New?
jbandi
 
Angular2 workshop
Nir Kaufman
 
AngularJS2 / TypeScript / CLI
Domenico Rutigliano
 
Angular1x and Angular 2 for Beginners
Oswald Campesato
 
Adventures with Angular 2
Dragos Ionita
 

Viewers also liked (8)

PDF
Angular 2 - Core Concepts
Fabio Biondi
 
PDF
Getting Started with Angular 2
FITC
 
PDF
Tech Webinar: Angular 2, Introduction to a new framework
Codemotion
 
PPTX
Introduction to Angularjs
Manish Shekhawat
 
PPTX
Angular vs. React
OPITZ CONSULTING Deutschland
 
PDF
Angular Seminar [한빛미디어 리얼타임 세미나]
Woojin Joe
 
PDF
Introduction à Angular 2
Vincent Caillierez
 
PDF
Angular Extreme Performance
Gustavo Costa
 
Angular 2 - Core Concepts
Fabio Biondi
 
Getting Started with Angular 2
FITC
 
Tech Webinar: Angular 2, Introduction to a new framework
Codemotion
 
Introduction to Angularjs
Manish Shekhawat
 
Angular vs. React
OPITZ CONSULTING Deutschland
 
Angular Seminar [한빛미디어 리얼타임 세미나]
Woojin Joe
 
Introduction à Angular 2
Vincent Caillierez
 
Angular Extreme Performance
Gustavo Costa
 
Ad

Similar to Building Universal Applications with Angular 2 (20)

PDF
Angular 2 for Java Developers
Yakov Fain
 
PDF
Angular2 Development for Java developers
Yakov Fain
 
PPTX
Angular2
Oswald Campesato
 
PPTX
An evening with Angular 2
Mike Melusky
 
PDF
An introduction to Angular2
Apptension
 
PPTX
An afternoon with angular 2
Mike Melusky
 
PPTX
Introduction to Angular2
Ivan Matiishyn
 
PPTX
Angular js 2
Ran Wahle
 
PDF
Angular 2 overview in 60 minutes
Loiane Groner
 
PDF
Angular for Java Enterprise Developers: Oracle Code One 2018
Loiane Groner
 
PPTX
The advantage of developing with TypeScript
Corley S.r.l.
 
PPTX
AngularConf2015
Alessandro Giorgetti
 
PPTX
Angular 2 with typescript
Tayseer_Emam
 
PDF
better-apps-angular-2-day1.pdf and home
ChethanGowda886434
 
PPTX
Angular2 for Beginners
Oswald Campesato
 
PPTX
Angular js 2.0 beta
Nagaraju Sangam
 
PDF
Angular 2.0
THanekamp
 
PPTX
Building a TV show with Angular, Bootstrap, and Web Services
David Giard
 
PDF
Feedback using Angularjs + Typescript at Serenytics
Adrien Chauve
 
PDF
Angular2 Upgrade
WealthBar Financial Services
 
Angular 2 for Java Developers
Yakov Fain
 
Angular2 Development for Java developers
Yakov Fain
 
An evening with Angular 2
Mike Melusky
 
An introduction to Angular2
Apptension
 
An afternoon with angular 2
Mike Melusky
 
Introduction to Angular2
Ivan Matiishyn
 
Angular js 2
Ran Wahle
 
Angular 2 overview in 60 minutes
Loiane Groner
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Loiane Groner
 
The advantage of developing with TypeScript
Corley S.r.l.
 
AngularConf2015
Alessandro Giorgetti
 
Angular 2 with typescript
Tayseer_Emam
 
better-apps-angular-2-day1.pdf and home
ChethanGowda886434
 
Angular2 for Beginners
Oswald Campesato
 
Angular js 2.0 beta
Nagaraju Sangam
 
Angular 2.0
THanekamp
 
Building a TV show with Angular, Bootstrap, and Web Services
David Giard
 
Feedback using Angularjs + Typescript at Serenytics
Adrien Chauve
 
Ad

Recently uploaded (20)

PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Digital Circuits, important subject in CS
contactparinay1
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 

Building Universal Applications with Angular 2