SlideShare a Scribd company logo
Moving From AngularJS to
Angular 2
By Ahamed Imran
@immysl
“AngularJS is a framework.
Angular 2 is a platform”
- Brad Green -
Why Angular 2?
• Cross platform
• Very good performance
• Good tooling support (IDEs and CLI tool)
• Ecosystem — RxJS, TypeScript, NativeScript, etc.
• Very good mobile support
“The value in TypeScript is in
writing safer code”
- John Papa -
Why TypeScript?
• Check for errors at compile time
• Good tooling support
• Is a mix of types, ES2015 and ESNext
• The fastest growing superset of JavaScript
• Compatibility with non-TypeScript libraries
Moving From AngularJS to  Angular 2
What has changed?
• There are components — No controllers
• There are services — No providers and factories
• There are zones — No $scope
• There are APIs for DOM manipulation — No jqLite
• One way data flow — No two way data flow
Moving From AngularJS to  Angular 2
Angular 2 Concepts
• Components
• Dependency Injection
• Data Binding
• Metadata / decorators
• Modules
Components
• Inputs
• Outputs / events
• Lifecycle
• Providers
• Template
Components Example
@Component({
selector: 'my-component',
providers: [MyService],
template: ‘<p *ngFor=”let item of list” (click)=”sendUpdate()”>{{ item }}</p>’,
styles: [‘p { font-size: 14px }’]
})
class MyComponent implements OnInit {
@Input() list;
@Output() update = new EventEmitter();
ngOnInit() { } // get async data
sendUpdate() { this.update.emit(‘some value’) }
}
Dependency Injection Example
@Component({
...
providers: [MyService]
})
export class MyComponent {
constructor(private service: MyService) {} // inject here
ngOnInit() {
service.getList(); // this is just a dummy line
}
}
Data Binding
• Interpolation
• Property binding (inputs)
• Event binding (outputs)
• Two-way binding
// example
<my-component [title]=”list” (update)=”getUpdate($event)”></my-component>
Metadata / Decorators
@Component({
selector: '...',
template: ‘<h2>{{title}}</h2>’
})
// common decorators
@Input()
@Output()
@Pipe()
@Injectable()
Modules
• Brand new — released yesterday
• Somewhat similar to AngularJS module
• An app needs to have a root module
• Separate modules based on features
• Not same as JavaScript / TypeScript modules
Modules Example
import { NgModule } from ‘@angular/core’;
import { BrowserModule } from ‘@angular/platform-browser’;
Import { MyComponent } from ‘./my.component’;
@NgModule({
imports: [BrowserModule],
providers: [MyService],
declarations: [MyComponent, MyDirective, MyPipe],
bootstrap: [AppComponent]
})
export class AppModule { }
Angular Libraries
• Router
• Form
• Upgrade
• Compiler
• Compiler-cli
Moving From AngularJS to  Angular 2
Angular CLI
• Official scaffolding and build tool for Angular 2
• Maintained by the Angular team
• Latest uses Webpack for build and server
• Currently as a command-line tool only
Other Tools
• Codelyzer — style guide checker
• Augury — Angular 2 debugger as a Chrome extension
• Lite-server — A live reload server for Angular
Demo
Norway
+47 959 23 712
oslo@exilesoft.com
Stortorvet 10
0155 Oslo
Norway
Sweden
+46 735 194 442
stockholm@exilesoft.com
Stockholmsvägen 33
181 33 Lidingö
Sweden
Australia
+61 412 446 105
sydney@exilesoft.com
Suite2.14, 32 Delhi Road
North Ryde, NSW 2113
Australia
Sri Lanka
+94 112 300 900
colombo@exilesoft.com
201, Sir James Peiris Mw.
Colombo 02
Sri Lanka
www.exilesoft.com

More Related Content

What's hot (20)

PPTX
Introducing angular
Columbia Developers Guild
 
PDF
React vs-angular-mobile
Michael Haberman
 
PDF
Introduction to react
kiranabburi
 
PPSX
React introduction
Kashyap Parmar
 
PDF
Marrying angular rails
Volker Tietz
 
PDF
2013 - Nate Abele Wield AngularJS like a Pro
PHP Conference Argentina
 
PDF
Reacting to the Isomorphic Buzz
Bruce Coddington
 
PDF
Angular basicschat
Yu Jin
 
PPTX
Understanding Javascript AJAX - Imrokraft
imrokraft
 
PDF
From ActiveRecord to EventSourcing
Emanuele DelBono
 
PDF
Infinum iOS Talks #4 - Making our VIPER more reactive
Infinum
 
PPTX
Angular js
Rajashekar Bhagavatula
 
PPTX
AngularJS
Malin De Silva
 
PPTX
Binary Studio Academy PRO. JS course. Lecture 2. backbone
Binary Studio
 
PPTX
Angular js
Baldeep Sohal
 
PDF
React.js - and how it changed our thinking about UI
Marcin Grzywaczewski
 
PPTX
AngularJS
LearningTech
 
PDF
modularity à la taliban
jonsterling
 
PDF
Angular js 2.0, ng poznań 20.11
Kamil Augustynowicz
 
ODP
Scheduler_session
shivani garg
 
Introducing angular
Columbia Developers Guild
 
React vs-angular-mobile
Michael Haberman
 
Introduction to react
kiranabburi
 
React introduction
Kashyap Parmar
 
Marrying angular rails
Volker Tietz
 
2013 - Nate Abele Wield AngularJS like a Pro
PHP Conference Argentina
 
Reacting to the Isomorphic Buzz
Bruce Coddington
 
Angular basicschat
Yu Jin
 
Understanding Javascript AJAX - Imrokraft
imrokraft
 
From ActiveRecord to EventSourcing
Emanuele DelBono
 
Infinum iOS Talks #4 - Making our VIPER more reactive
Infinum
 
AngularJS
Malin De Silva
 
Binary Studio Academy PRO. JS course. Lecture 2. backbone
Binary Studio
 
Angular js
Baldeep Sohal
 
React.js - and how it changed our thinking about UI
Marcin Grzywaczewski
 
AngularJS
LearningTech
 
modularity à la taliban
jonsterling
 
Angular js 2.0, ng poznań 20.11
Kamil Augustynowicz
 
Scheduler_session
shivani garg
 

Viewers also liked (16)

PDF
Hojadevidapersonal1.docx
Aleja Chalama
 
DOCX
Casos
Aleja Chalama
 
PPTX
Zimmilo ENG July 2016
Roman Ruzinsky
 
PDF
Resume_Mayalagu updated
Mayalagu Karuppiah
 
PPTX
El romance tg
Cristina Dassum
 
PDF
شهادات محمد عطية.PDF
Mohammed Timraz
 
PDF
Flyer 4x9
Florence Turk Weber
 
PPTX
progress_PPT
Pranjal Barman
 
DOCX
Harinanden New Resume v5
Harinanden VK
 
DOCX
R. Seth Penny-Percentage Paper
Rohan Seth
 
PDF
(2011) Rigaud, David, Daudet - A Parametric Model of Piano Tuning
François Rigaud
 
PPTX
Forxtrust
Friday David
 
PPTX
the 21st Century Digital Learner
charmesintos123
 
PDF
Eco borbur ingenieros constructores
Jennsy Gonzalez
 
PPTX
Smokeless tobacco
Ankit Verma
 
Hojadevidapersonal1.docx
Aleja Chalama
 
Zimmilo ENG July 2016
Roman Ruzinsky
 
Resume_Mayalagu updated
Mayalagu Karuppiah
 
El romance tg
Cristina Dassum
 
شهادات محمد عطية.PDF
Mohammed Timraz
 
progress_PPT
Pranjal Barman
 
Harinanden New Resume v5
Harinanden VK
 
R. Seth Penny-Percentage Paper
Rohan Seth
 
(2011) Rigaud, David, Daudet - A Parametric Model of Piano Tuning
François Rigaud
 
Forxtrust
Friday David
 
the 21st Century Digital Learner
charmesintos123
 
Eco borbur ingenieros constructores
Jennsy Gonzalez
 
Smokeless tobacco
Ankit Verma
 
Ad

Similar to Moving From AngularJS to Angular 2 (20)

PDF
better-apps-angular-2-day1.pdf and home
ChethanGowda886434
 
PPTX
Angular js 2
Ran Wahle
 
PPTX
yrs of IT experience in enterprise programming
narasimhulum1623
 
PPTX
Introduction to Angular2
Ivan Matiishyn
 
PPTX
What's new in Angular 2?
Alfred Jett Grandeza
 
PDF
MEAN Stack Warm-up
Troy Miles
 
PPTX
angular-concepts-introduction-slides.pptx
shekharmpatil1309
 
PDF
Angular 2 - The Next Framework
Commit University
 
PDF
From MEAN to the MERN Stack
Troy Miles
 
PDF
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
PPTX
Angular 4 Introduction Tutorial
Scott Lee
 
PDF
Angular 4 for Java Developers
Yakov Fain
 
PPTX
Angularjs Basics
Jayantha Sirisena
 
PPTX
Introduction to AngularJs
murtazahaveliwala
 
PDF
Building Blocks of Angular 2 and ASP.NET Core
Levi Fuller
 
PDF
Angular2 with type script
Ravi Mone
 
PDF
Angular2 with TypeScript
Rohit Bishnoi
 
PDF
Angular2
SitaPrajapati
 
PPTX
Angular js 2.0 beta
Nagaraju Sangam
 
better-apps-angular-2-day1.pdf and home
ChethanGowda886434
 
Angular js 2
Ran Wahle
 
yrs of IT experience in enterprise programming
narasimhulum1623
 
Introduction to Angular2
Ivan Matiishyn
 
What's new in Angular 2?
Alfred Jett Grandeza
 
MEAN Stack Warm-up
Troy Miles
 
angular-concepts-introduction-slides.pptx
shekharmpatil1309
 
Angular 2 - The Next Framework
Commit University
 
From MEAN to the MERN Stack
Troy Miles
 
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
Angular 4 Introduction Tutorial
Scott Lee
 
Angular 4 for Java Developers
Yakov Fain
 
Angularjs Basics
Jayantha Sirisena
 
Introduction to AngularJs
murtazahaveliwala
 
Building Blocks of Angular 2 and ASP.NET Core
Levi Fuller
 
Angular2 with type script
Ravi Mone
 
Angular2 with TypeScript
Rohit Bishnoi
 
Angular2
SitaPrajapati
 
Angular js 2.0 beta
Nagaraju Sangam
 
Ad

Recently uploaded (20)

PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 

Moving From AngularJS to Angular 2

  • 1. Moving From AngularJS to Angular 2 By Ahamed Imran @immysl
  • 2. “AngularJS is a framework. Angular 2 is a platform” - Brad Green -
  • 3. Why Angular 2? • Cross platform • Very good performance • Good tooling support (IDEs and CLI tool) • Ecosystem — RxJS, TypeScript, NativeScript, etc. • Very good mobile support
  • 4. “The value in TypeScript is in writing safer code” - John Papa -
  • 5. Why TypeScript? • Check for errors at compile time • Good tooling support • Is a mix of types, ES2015 and ESNext • The fastest growing superset of JavaScript • Compatibility with non-TypeScript libraries
  • 7. What has changed? • There are components — No controllers • There are services — No providers and factories • There are zones — No $scope • There are APIs for DOM manipulation — No jqLite • One way data flow — No two way data flow
  • 9. Angular 2 Concepts • Components • Dependency Injection • Data Binding • Metadata / decorators • Modules
  • 10. Components • Inputs • Outputs / events • Lifecycle • Providers • Template
  • 11. Components Example @Component({ selector: 'my-component', providers: [MyService], template: ‘<p *ngFor=”let item of list” (click)=”sendUpdate()”>{{ item }}</p>’, styles: [‘p { font-size: 14px }’] }) class MyComponent implements OnInit { @Input() list; @Output() update = new EventEmitter(); ngOnInit() { } // get async data sendUpdate() { this.update.emit(‘some value’) } }
  • 12. Dependency Injection Example @Component({ ... providers: [MyService] }) export class MyComponent { constructor(private service: MyService) {} // inject here ngOnInit() { service.getList(); // this is just a dummy line } }
  • 13. Data Binding • Interpolation • Property binding (inputs) • Event binding (outputs) • Two-way binding // example <my-component [title]=”list” (update)=”getUpdate($event)”></my-component>
  • 14. Metadata / Decorators @Component({ selector: '...', template: ‘<h2>{{title}}</h2>’ }) // common decorators @Input() @Output() @Pipe() @Injectable()
  • 15. Modules • Brand new — released yesterday • Somewhat similar to AngularJS module • An app needs to have a root module • Separate modules based on features • Not same as JavaScript / TypeScript modules
  • 16. Modules Example import { NgModule } from ‘@angular/core’; import { BrowserModule } from ‘@angular/platform-browser’; Import { MyComponent } from ‘./my.component’; @NgModule({ imports: [BrowserModule], providers: [MyService], declarations: [MyComponent, MyDirective, MyPipe], bootstrap: [AppComponent] }) export class AppModule { }
  • 17. Angular Libraries • Router • Form • Upgrade • Compiler • Compiler-cli
  • 19. Angular CLI • Official scaffolding and build tool for Angular 2 • Maintained by the Angular team • Latest uses Webpack for build and server • Currently as a command-line tool only
  • 20. Other Tools • Codelyzer — style guide checker • Augury — Angular 2 debugger as a Chrome extension • Lite-server — A live reload server for Angular
  • 21. Demo
  • 22. Norway +47 959 23 712 [email protected] Stortorvet 10 0155 Oslo Norway Sweden +46 735 194 442 [email protected] Stockholmsvägen 33 181 33 Lidingö Sweden Australia +61 412 446 105 [email protected] Suite2.14, 32 Delhi Road North Ryde, NSW 2113 Australia Sri Lanka +94 112 300 900 [email protected] 201, Sir James Peiris Mw. Colombo 02 Sri Lanka www.exilesoft.com