SlideShare una empresa de Scribd logo
1 de 49
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 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??

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Angular 2 Crash Course
Angular  2 Crash CourseAngular  2 Crash Course
Angular 2 Crash Course
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
Angular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code levelAngular 1.x vs 2 - In code level
Angular 1.x vs 2 - In code level
 
Angular 2 - An Introduction
Angular 2 - An IntroductionAngular 2 - An Introduction
Angular 2 - An Introduction
 
Angular2 with TypeScript
Angular2 with TypeScript Angular2 with TypeScript
Angular2 with TypeScript
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
Migrating an application from Angular 1 to Angular 2
Migrating an application from Angular 1 to Angular 2 Migrating an application from Angular 1 to Angular 2
Migrating an application from Angular 1 to Angular 2
 
Angular2
Angular2Angular2
Angular2
 
Angular 2
Angular 2Angular 2
Angular 2
 
Talk for DevFest 2021 - GDG Bénin
Talk for DevFest 2021 - GDG BéninTalk for DevFest 2021 - GDG Bénin
Talk for DevFest 2021 - GDG Bénin
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2
 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next Framework
 
Angular 2 - Better or worse
Angular 2 - Better or worseAngular 2 - Better or worse
Angular 2 - Better or worse
 
Angular2 intro
Angular2 introAngular2 intro
Angular2 intro
 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core concepts
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
Quick introduction to Angular 4 for AngularJS 1.5 developers
Quick introduction to Angular 4 for AngularJS 1.5 developersQuick introduction to Angular 4 for AngularJS 1.5 developers
Quick introduction to Angular 4 for AngularJS 1.5 developers
 

Destacado

Gwtar formation-google-web-toolkit-creation-d-applications-riches
Gwtar formation-google-web-toolkit-creation-d-applications-richesGwtar formation-google-web-toolkit-creation-d-applications-riches
Gwtar formation-google-web-toolkit-creation-d-applications-riches
CERTyou Formation
 
Digital wallet (e-wallet)
Digital wallet  (e-wallet)Digital wallet  (e-wallet)
Digital wallet (e-wallet)
Krishna Kumar
 

Destacado (12)

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

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

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

El viaje de Angular1 a Angular2
El viaje de Angular1 a Angular2El viaje de Angular1 a Angular2
El viaje de Angular1 a Angular2
 
AngularConf2016 - A leap of faith !?
AngularConf2016 - A leap of faith !?AngularConf2016 - A leap of faith !?
AngularConf2016 - A leap of faith !?
 
Angular.ppt
Angular.pptAngular.ppt
Angular.ppt
 
Angular TS(typescript)
Angular TS(typescript)Angular TS(typescript)
Angular TS(typescript)
 
Angular
AngularAngular
Angular
 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
 
Angular 2 - How we got here?
Angular 2 - How we got here?Angular 2 - How we got here?
Angular 2 - How we got here?
 
What's New in Angular 4 | Angular 4 Features | Angular 4 Changes | Angular Tu...
What's New in Angular 4 | Angular 4 Features | Angular 4 Changes | Angular Tu...What's New in Angular 4 | Angular 4 Features | Angular 4 Changes | Angular Tu...
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
Best episode ever: Angular 2 from the perspective of an Angular 1 developerBest episode ever: Angular 2 from the perspective of an Angular 1 developer
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]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
 
Getting to Angular 2
Getting to Angular 2Getting to Angular 2
Getting to Angular 2
 
5 Key Benefits of Migration
5 Key Benefits of Migration5 Key Benefits of Migration
5 Key Benefits of Migration
 
Angular 14.pdf
Angular 14.pdfAngular 14.pdf
Angular 14.pdf
 
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Angular JS 2_0 BCS CTO_in_Res V3
Angular JS 2_0 BCS CTO_in_Res V3Angular JS 2_0 BCS CTO_in_Res V3
Angular JS 2_0 BCS CTO_in_Res V3
 
Introduction to Angular2
Introduction to Angular2Introduction to Angular2
Introduction to Angular2
 
Angular 2.docx
Angular 2.docxAngular 2.docx
Angular 2.docx
 
Introduction to Angular2
Introduction to Angular2Introduction to Angular2
Introduction to Angular2
 
Angular 6 - The Complete Guide
Angular 6 - The Complete GuideAngular 6 - The Complete Guide
Angular 6 - The Complete Guide
 
Angular meetup 2 2019-08-29
Angular meetup 2   2019-08-29Angular meetup 2   2019-08-29
Angular meetup 2 2019-08-29
 

Más de Laurent Duveau

Más de Laurent Duveau (20)

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

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

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