SlideShare a Scribd company logo
ANGULAR 2…
SO CAN I USE IT NOW??
Laurent Duveau
July 7, 2016
1
LAURENT DUVEAU
@LaurentDuveau
Founder of the Angular Academy
2-day Angular Classroom Training
23 classes in the last 10 months
Montreal, Quebec, Toronto, Vancouver,
Ottawa, Calgary, …
THIS TALK IS ABOUT…
Angular 2... so can I use it now??
ANGULAR 2 IS IN
RELEASE CANDIDATE
#RC4
www.angular.io
ANGULAR 2
FINAL ?
everything’s
changed but
nothing is
different
it is still a client side MVC
framework, but adopting a
modern approach
(ES2015, Web Components)
most of the concepts you’ve
learned from ng1 will carry over…
…implementations and syntax
are changing
“Angular 1.x will be supported at
least 1.5 - 2 years after the first
*stable* release of Angular 2”
- Brad Green, Angular team
Angular 2 is built
using TypeScript
Wait…
you can use TypeScript
or JavaScript (ES2015)
you should learn TypeScript
www.typescriptlang.org/docs/tutorial.html
really
TypeScript
• Types
• Annotations
ES6
• Classes
• Modules
ES5
How does TypeScript work?
TypeScript
file.ts
JavaScript
file.js
TypeScript Compiler
Output ES3/ES5/ES6/…
compliant code
“Transpiling”
Controller
Web Component
ES6 Module
$scope
jqLite
Module
Raw DOM
AngularJS 1.x Angular 2
Directives
CODE…
AngularJS 1.x Angular 2
<div ng-controller="TodoController">
<input type="text" ng-model="newTodoTitle">
<button ng-click="addTodo()">+</button>
<tab-container>
<tab-pane title="Laurent">
<div ng-repeat="todo in todos">
<input type="checkbox" ng-model="todo.done">
{{todo.title}}
<button ng-click="deleteTodo(todo)">X</button>
</div>
</tab-pane>
...
<div>
<input type="text" [(ngModel)]="newTodoTitle">
<button (click)="addTodo()">+</buton>
<tab-container>
<tab-pane title="Laurent">
<div *ngFor="let todo of todos">
<input type="checkbox"
[checked]="todo.done">
{{todo.title}}
<button (click)="deleteTodo(todo)">X</button>
</div>
</tab-pane>
...
ANGULAR 2 COMPONENT
Angular 1.x: Directives and Controllers were two different things
Angular 2: Directives and Controllers unified into the Component model
7/9/2016 19
@Component({
selector:'tab-container'
})
class TabContainer {
...
constructor(todos:Array<Todo>) {
this.todos = todos;
}
deleteTodo(selectedTodo:Todo) { ... }
}
NG1 VS NG2
ng1 has 46 directives
ng2 has () and []
7/9/2016 20
DEMONSTRATION
MIGRATION FROM
ANGULAR 1
22
MIGRATION…
ng1
ng2
TWO PHASES
24
ng1 ng2
PREPARING THE UPGRADE
Things you can do today to make your life easier:
Follow the Angular Style Guide!
Use .service() instead of .factory()
Remove dependencies on $scope
•Use controller as and this
Use the new component syntax (ng 1.5)
Adopt TypeScript!
ADOPT TYPESCRIPT!!
25
UPGRADE STRATEGIES
2 options:
Big Bang: Start a spike in Angular 2 and replace entire
app once done
Incremental: Upgrade existing app one service or
component at a time
26
BIG BANG
27
BIG BANG
28
BIG BANG
29
INCREMENTAL UPGRADE
30
INCREMENTAL UPGRADE
31
INCREMENTAL UPGRADE
32
INCREMENTAL UPGRADE
33
NGUPGRADE
Angular 1 + 2 together!
Include Angular 2 and the upgrade module (ngUpgrade)
Replace Angular 1 bootstrap with Angular 2 bootstrap
Pick directive to upgrade and change its template/controller
Export ng2 component in Angular 1 app
Repeat…
34
https://angular.io/docs/ts/latest/guide/upgrade.html
NGUPGRADE
7/9/2016 35
UPGRADE ADAPTER
Create an upgrade adapter instance
Bootstrap the ng1 app from the adapter (remove ng-app=…)
36
import {UpgradeAdapter} from '@angular/upgrade';
export const upgradeAdapter = new UpgradeAdapter();
import {upgradeAdapter} from 'upgrade-adapter';
angular.module('store-app', [...]);
upgradeAdapter
.bootstrap(document.body, ['store-app']);
NG2 => NG1
DOWNGRADING NG2 COMPONENTS…
… to use them as ng1 directive
38
@Component({
selector: 'product-list-item',
template: `
<a href="#/product/{{product.id}}">
<img [src]="product.image">
<span>{{product.name}}</span>
</a>
`
})
export class ProductListItemComponent {
@Input() product: Product;
}
ng2
DOWNGRADING NG2 COMPONENTS
Create an ng1 module with directive
39
import {upgradeAdapter} from 'upgrade-adapter';
import {ProductListItemComponent} from '...';
angular
.module('ang2-components', [])
.directive('productListItem',
upgradeAdapter
.downgradeNg2Component(ProductListItemComponent)
);
ng1
DOWNGRADING NG2 COMPONENTS
Inject our new module
40
angular.module('store-app', [
...
'ang2-components'
]);
ng1
DOWNGRADING NG2 COMPONENTS
Use the directive!
41
<ul>
<li ng-repeat="product in products">
<product-list-item [product]="product">
</product-list-item>
</li>
</ul>
ng1
NG1 => NG2
UPGRADING NG1 COMPONENTS
43
angular
.module('ang1-components', [])
.component('ang1Component', {
templateUrl: '...',
transclude: true,
bindings: {
closed: '<',
title: '@',
toggle: '&'
},
controller: function () { ... }
})
ng1
UPGRADING NG1 COMPONENTS
Migration from Angular 1
44
@Component({
selector: 'product-detail-component',
templateUrl: '...',
})
export class ProductDetailComponent {
...
}
ng2
UPGRADING NG1 COMPONENTS
Migration from Angular 1
45
import {upgradeAdapter} from 'upgrade-adapter';
const Ang1Component =
upgradeAdapter.upgradeNg1Component('ang1Component');
@Component({
selector: 'product-detail-component',
templateUrl: '...',
directives: [Ang1Component]
})
export class ProductDetailComponent {
...
}
ng2
UPGRADING NG1 COMPONENTS
Use it in ng2 component’s template!
46
<div>
{{product.name}}
<ang1-component
[title]="productCaption"
(toggle)="toggleCaption($event.closed)">
</ang1-component>
<div>
ng2 template
DEMONSTRATION
Thank you!
Angular 2... so can I use it now??

More Related Content

PDF
The evolution of Angular 2 @ AngularJS Munich Meetup #5
PDF
Introduction to Angular for .NET Developers
PDF
Building Universal Applications with Angular 2
PDF
Angular2 with type script
PDF
Angular 2 : le réveil de la force
PDF
Angular 2: What's New?
PDF
Adventures with Angular 2
PDF
Angular 2 - Core Concepts
The evolution of Angular 2 @ AngularJS Munich Meetup #5
Introduction to Angular for .NET Developers
Building Universal Applications with Angular 2
Angular2 with type script
Angular 2 : le réveil de la force
Angular 2: What's New?
Adventures with Angular 2
Angular 2 - Core Concepts

What's hot (20)

ODP
Introduction to Angular 2
PDF
Angular 2 Crash Course
PDF
Introduction to Angular 2
PPTX
Angular1x and Angular 2 for Beginners
PPTX
Angular 1.x vs 2 - In code level
PDF
Angular 2 - An Introduction
PDF
Angular2 with TypeScript
PDF
Introduction to angular 2
PPTX
Migrating an application from Angular 1 to Angular 2
PPTX
PPTX
Talk for DevFest 2021 - GDG Bénin
PDF
Getting Started with Angular 2
PDF
Angular 2 - The Next Framework
PPTX
Angular 2 - Better or worse
PDF
Angular2 intro
PDF
Angular 2: core concepts
PDF
Angular 2 overview
PPTX
Introduction to angular 2
PDF
Quick introduction to Angular 4 for AngularJS 1.5 developers
Introduction to Angular 2
Angular 2 Crash Course
Introduction to Angular 2
Angular1x and Angular 2 for Beginners
Angular 1.x vs 2 - In code level
Angular 2 - An Introduction
Angular2 with TypeScript
Introduction to angular 2
Migrating an application from Angular 1 to Angular 2
Talk for DevFest 2021 - GDG Bénin
Getting Started with Angular 2
Angular 2 - The Next Framework
Angular 2 - Better or worse
Angular2 intro
Angular 2: core concepts
Angular 2 overview
Introduction to angular 2
Quick introduction to Angular 4 for AngularJS 1.5 developers
Ad

Viewers also liked (12)

PDF
Introduction à Angular 2
PDF
Introduction to Angular with TypeScript for .NET Developers
PDF
Introduction to SPAs with AngularJS
PDF
DevTeach Ottawa - Silverlight5 and HTML5
PDF
Gwtar formation-google-web-toolkit-creation-d-applications-riches
PPTX
Maximizing ROI in eCommerce with Search
PPTX
Digital wallet
PPTX
Digital wallet (e-wallet)
PPTX
Le futur de AngularJS (2.0)
PDF
Introduction à Angular 2
PDF
Visual Design with Data
PDF
Build Features, Not Apps
Introduction à Angular 2
Introduction to Angular with TypeScript for .NET Developers
Introduction to SPAs with AngularJS
DevTeach Ottawa - Silverlight5 and HTML5
Gwtar formation-google-web-toolkit-creation-d-applications-riches
Maximizing ROI in eCommerce with Search
Digital wallet
Digital wallet (e-wallet)
Le futur de AngularJS (2.0)
Introduction à Angular 2
Visual Design with Data
Build Features, Not Apps
Ad

Similar to Angular 2... so can I use it now?? (20)

PPTX
Angular _ Lifecycle Hooks - Byteridge.pptx
PDF
El viaje de Angular1 a Angular2
PPTX
AngularConf2016 - A leap of faith !?
PPT
Angular.ppt
PPTX
Angular TS(typescript)
PPTX
Angular
PDF
Angular 1.x reloaded: improve your app now! and get ready for 2.0
PDF
Angular 2 - How we got here?
PDF
What's New in Angular 4 | Angular 4 Features | Angular 4 Changes | Angular Tu...
ODP
Best episode ever: Angular 2 from the perspective of an Angular 1 developer
PDF
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
PDF
Getting to Angular 2
PDF
5 Key Benefits of Migration
PDF
Angular 14.pdf
PPTX
Angular 2.0
PDF
Angular JS 2_0 BCS CTO_in_Res V3
PPTX
Introduction to Angular2
DOCX
Angular 2.docx
PPTX
Introduction to Angular2
ODP
Angular 6 - The Complete Guide
Angular _ Lifecycle Hooks - Byteridge.pptx
El viaje de Angular1 a Angular2
AngularConf2016 - A leap of faith !?
Angular.ppt
Angular TS(typescript)
Angular
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 2 - How we got here?
What's New in Angular 4 | Angular 4 Features | Angular 4 Changes | Angular Tu...
Best episode ever: Angular 2 from the perspective of an Angular 1 developer
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
Getting to Angular 2
5 Key Benefits of Migration
Angular 14.pdf
Angular 2.0
Angular JS 2_0 BCS CTO_in_Res V3
Introduction to Angular2
Angular 2.docx
Introduction to Angular2
Angular 6 - The Complete Guide

More from Laurent Duveau (20)

PDF
Shit happens… debugging an Angular app.
PDF
8 things you didn't know about the Angular Router, you won't believe #6!
PDF
De 0 à Angular en 1h30! (french)
PDF
Angular 6, CLI 6, Material 6 (french)
PDF
Angular Advanced Routing
PDF
Debugging an Angular App
PDF
TypeScript: Angular's Secret Weapon
PDF
Introduction to Angular for .NET Developers
PDF
TypeScript: Angular's Secret Weapon
PDF
Introduction to Angular for .NET Developers
PDF
Introduction to Angular for .NET Developers
PPTX
ngconf 2016 (french)
PDF
Microsoft Edge pour les développeurs web
PDF
Microsoft Edge pour les développeurs web
PDF
Xamarin.Forms [french]
PDF
Back from Xamarin Evolve 2014
PDF
Windows App Studio
PDF
Windows 8: Live tiles, badges et notifications toasts [french]
PPTX
L'opportunité Windows 8 pour les développeurs
PPTX
Building apps for WP8 and Win8
Shit happens… debugging an Angular app.
8 things you didn't know about the Angular Router, you won't believe #6!
De 0 à Angular en 1h30! (french)
Angular 6, CLI 6, Material 6 (french)
Angular Advanced Routing
Debugging an Angular App
TypeScript: Angular's Secret Weapon
Introduction to Angular for .NET Developers
TypeScript: Angular's Secret Weapon
Introduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
ngconf 2016 (french)
Microsoft Edge pour les développeurs web
Microsoft Edge pour les développeurs web
Xamarin.Forms [french]
Back from Xamarin Evolve 2014
Windows App Studio
Windows 8: Live tiles, badges et notifications toasts [french]
L'opportunité Windows 8 pour les développeurs
Building apps for WP8 and Win8

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation theory and applications.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Dropbox Q2 2025 Financial Results & Investor Presentation
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
Encapsulation theory and applications.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Chapter 3 Spatial Domain Image Processing.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
NewMind AI Monthly Chronicles - July 2025
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Spectral efficient network and resource selection model in 5G networks
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Building Integrated photovoltaic BIPV_UPV.pdf
Understanding_Digital_Forensics_Presentation.pptx
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing

Angular 2... so can I use it now??