際際滷

際際滷Share a Scribd company logo
ROUTING TO
COMPONENTS
/Chris Caplinger @unicode_snowman
COMPONENT OVERVIEW
Components Vs. Directives ?
Directive + Template === Component
class Component extends Directive { ... }
import { ComponentAnnotation as Component, ViewAnnotation as View, bootstrap
import { NgFor } from 'angular2/directives'
@Component({
selector: 'things'
})
@View({
template:
`<div>
<h5>A LIST OF THINGS!!!</h5>
<ul>
<li *ng-for="#thing of things; #i = index" (click)="onClickIt
{{thing}}
</li>
</ul>
</div>`,
import { bootstrap } from 'angular2/angular2';
...
bootstrap(Things)
...
<things></things>
APP ARCHITECTURE / ROUTING
Routing to components
$stateProvider
.state('report',{
views: {
'filters': {
templateUrl: 'report-filters.html',
controller: function(){ ... filters view controller ... }
},
'tabledata': {
templateUrl: 'report-table.html',
controller: function(){ ... tabledata view controller ... }
},
'graph': {
templateUrl: 'report-graph.html',
controller: function(){ ... graph view controller ... }
}
}
COMPONENT ROUTER
AppController.$routeConfig = [
{ path: '/report', components: { filters: 'filters', tableData: 'tableDat
]
...
<div class="container">
<div ng-outlet="filters"></div>
<div ng-outlet="tableData"></div>
<div ng-outlet="graph"></div>
</div>
@Component({ selector: 'app' })
@View({
template: `
<div class="container">
<router-outlet name="filters"></router-outlet>
<router-outlet name="tableData"></router-outlet>
<router-outlet name="graph"></router-outlet>
</div> `,
directives: [RouterOutlet]
})
@RouteConfig([
{ path: '/report', components: { filters: Filters, tableData: TableData
])
class App { }
Routing to components
ANGULAR 1 => ANGULAR 2 MIGRATION
QUESTIONS?

More Related Content

What's hot (20)

Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Eyal Vardi
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Aaron Saunders
How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And Navigation
Eyal Vardi
Introduction to Angular2
Introduction to Angular2Introduction to Angular2
Introduction to Angular2
Ivan Matiishyn
Solid angular
Solid angularSolid angular
Solid angular
Nir Kaufman
Migrating to Angular 2
Migrating to Angular 2Migrating to Angular 2
Migrating to Angular 2
FITC
Redux in Angular2 for jsbe
Redux in Angular2 for jsbeRedux in Angular2 for jsbe
Redux in Angular2 for jsbe
Brecht Billiet
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
Eyal Vardi
Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016
Nir Kaufman
Angular 2.0 - What to expect
Angular 2.0 - What to expectAngular 2.0 - What to expect
Angular 2.0 - What to expect
Allan Marques Baptista
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
Barcamp Saigon
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
Anuradha Bandara
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
Introduction To Angular's reactive forms
Introduction To Angular's reactive formsIntroduction To Angular's reactive forms
Introduction To Angular's reactive forms
Nir Kaufman
View controller life cycle
View controller life cycleView controller life cycle
View controller life cycle
SV.CO
Angular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of StatesAngular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of States
Oren Farhi
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)
Fabio Biondi
Deep Dive into React Hooks
Deep Dive into React HooksDeep Dive into React Hooks
Deep Dive into React Hooks
Felix K端hl
Angular 1.x in action now
Angular 1.x in action nowAngular 1.x in action now
Angular 1.x in action now
GDG Odessa
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Eyal Vardi
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Aaron Saunders
How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And Navigation
Eyal Vardi
Introduction to Angular2
Introduction to Angular2Introduction to Angular2
Introduction to Angular2
Ivan Matiishyn
Solid angular
Solid angularSolid angular
Solid angular
Nir Kaufman
Migrating to Angular 2
Migrating to Angular 2Migrating to Angular 2
Migrating to Angular 2
FITC
Redux in Angular2 for jsbe
Redux in Angular2 for jsbeRedux in Angular2 for jsbe
Redux in Angular2 for jsbe
Brecht Billiet
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
Eyal Vardi
Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016
Nir Kaufman
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
Barcamp Saigon
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
Introduction To Angular's reactive forms
Introduction To Angular's reactive formsIntroduction To Angular's reactive forms
Introduction To Angular's reactive forms
Nir Kaufman
View controller life cycle
View controller life cycleView controller life cycle
View controller life cycle
SV.CO
Angular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of StatesAngular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of States
Oren Farhi
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)
Fabio Biondi
Deep Dive into React Hooks
Deep Dive into React HooksDeep Dive into React Hooks
Deep Dive into React Hooks
Felix K端hl
Angular 1.x in action now
Angular 1.x in action nowAngular 1.x in action now
Angular 1.x in action now
GDG Odessa

Viewers also liked (12)

2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: Switch2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: Switch
Cheng-Yi Yu
SSL Technology
SSL TechnologySSL Technology
SSL Technology
Pushpraj Verma
Fundamental of Secure Socket Layer (SSL) | Part - 2
Fundamental of Secure Socket Layer (SSL) | Part - 2 Fundamental of Secure Socket Layer (SSL) | Part - 2
Fundamental of Secure Socket Layer (SSL) | Part - 2
Vishal Kumar
CCNA Routing Protocols
CCNA Routing Protocols CCNA Routing Protocols
CCNA Routing Protocols
Mansour Naslcheraghi
Cryptography Simplified - Symmetric Key, Public Key, PKI, Digital Signature, ...
Cryptography Simplified - Symmetric Key, Public Key, PKI, Digital Signature, ...Cryptography Simplified - Symmetric Key, Public Key, PKI, Digital Signature, ...
Cryptography Simplified - Symmetric Key, Public Key, PKI, Digital Signature, ...
Muhammad Faisal Naqvi, CISSP, CISA, AMBCI, ITIL, ISMS LA n Master
Network device management
Network device managementNetwork device management
Network device management
Arnold Derrick Kinney
Secure Socket Layer
Secure Socket LayerSecure Socket Layer
Secure Socket Layer
Naveen Kumar
Lecture 6 web security
Lecture 6 web securityLecture 6 web security
Lecture 6 web security
rajakhurram
Introduction to Secure Sockets Layer
Introduction to Secure Sockets LayerIntroduction to Secure Sockets Layer
Introduction to Secure Sockets Layer
Nascenia IT
Dhcp ppt
Dhcp pptDhcp ppt
Dhcp ppt
Hema Dhariwal
CCNA Routing Protocols
CCNA Routing ProtocolsCCNA Routing Protocols
CCNA Routing Protocols
Dsunte Wilson
CCNA Advanced Routing Protocols
CCNA Advanced Routing ProtocolsCCNA Advanced Routing Protocols
CCNA Advanced Routing Protocols
Dsunte Wilson
2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: Switch2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: Switch
Cheng-Yi Yu
Fundamental of Secure Socket Layer (SSL) | Part - 2
Fundamental of Secure Socket Layer (SSL) | Part - 2 Fundamental of Secure Socket Layer (SSL) | Part - 2
Fundamental of Secure Socket Layer (SSL) | Part - 2
Vishal Kumar
Secure Socket Layer
Secure Socket LayerSecure Socket Layer
Secure Socket Layer
Naveen Kumar
Lecture 6 web security
Lecture 6 web securityLecture 6 web security
Lecture 6 web security
rajakhurram
Introduction to Secure Sockets Layer
Introduction to Secure Sockets LayerIntroduction to Secure Sockets Layer
Introduction to Secure Sockets Layer
Nascenia IT
CCNA Routing Protocols
CCNA Routing ProtocolsCCNA Routing Protocols
CCNA Routing Protocols
Dsunte Wilson
CCNA Advanced Routing Protocols
CCNA Advanced Routing ProtocolsCCNA Advanced Routing Protocols
CCNA Advanced Routing Protocols
Dsunte Wilson

Recently uploaded (20)

Structural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptxStructural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptx
gunjalsachin
危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)
危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)
危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)
危 / HIFLUX Co., Ltd.
UNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCH
UNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCHUNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCH
UNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCH
Sridhar191373
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
Forensic Science Digital Forensics Digital Evidence The Digital Forensi...
Forensic Science  Digital Forensics  Digital Evidence  The Digital Forensi...Forensic Science  Digital Forensics  Digital Evidence  The Digital Forensi...
Forensic Science Digital Forensics Digital Evidence The Digital Forensi...
ManiMaran230751
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
Application Security and Secure Software Development Lifecycle
Application  Security and Secure Software Development LifecycleApplication  Security and Secure Software Development Lifecycle
Application Security and Secure Software Development Lifecycle
DrKavithaP1
Digital Crime Substantive Criminal Law General Conditions Offenses In...
Digital Crime  Substantive Criminal Law  General Conditions  Offenses  In...Digital Crime  Substantive Criminal Law  General Conditions  Offenses  In...
Digital Crime Substantive Criminal Law General Conditions Offenses In...
ManiMaran230751
HVAC Air Filter Equipment-Catalouge-Final.pdf
HVAC Air Filter Equipment-Catalouge-Final.pdfHVAC Air Filter Equipment-Catalouge-Final.pdf
HVAC Air Filter Equipment-Catalouge-Final.pdf
FILTRATION ENGINEERING & CUNSULTANT
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdfSoftware_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
VanshMunjal7
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
危 / HIFLUX Co., Ltd.
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
ISO 5011 Air Filter Catalogues .pdf
ISO 5011 Air Filter Catalogues      .pdfISO 5011 Air Filter Catalogues      .pdf
ISO 5011 Air Filter Catalogues .pdf
FILTRATION ENGINEERING & CUNSULTANT
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
[HIFLUX] High Pressure Tube Support Catalog 2025
[HIFLUX] High Pressure Tube Support Catalog 2025[HIFLUX] High Pressure Tube Support Catalog 2025
[HIFLUX] High Pressure Tube Support Catalog 2025
危 / HIFLUX Co., Ltd.
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdfISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
FILTRATION ENGINEERING & CUNSULTANT
Influence line diagram for truss in a robust
Influence line diagram for truss in a robustInfluence line diagram for truss in a robust
Influence line diagram for truss in a robust
ParthaSengupta26
Structural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptxStructural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptx
gunjalsachin
危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)
危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)
危 渚狩 豺企襦蠏 2025 (Lok Fitting Catalog 2025)
危 / HIFLUX Co., Ltd.
UNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCH
UNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCHUNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCH
UNIT-4-PPT UNIT COMMITMENT AND ECONOMIC DISPATCH
Sridhar191373
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
Forensic Science Digital Forensics Digital Evidence The Digital Forensi...
Forensic Science  Digital Forensics  Digital Evidence  The Digital Forensi...Forensic Science  Digital Forensics  Digital Evidence  The Digital Forensi...
Forensic Science Digital Forensics Digital Evidence The Digital Forensi...
ManiMaran230751
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
Application Security and Secure Software Development Lifecycle
Application  Security and Secure Software Development LifecycleApplication  Security and Secure Software Development Lifecycle
Application Security and Secure Software Development Lifecycle
DrKavithaP1
Digital Crime Substantive Criminal Law General Conditions Offenses In...
Digital Crime  Substantive Criminal Law  General Conditions  Offenses  In...Digital Crime  Substantive Criminal Law  General Conditions  Offenses  In...
Digital Crime Substantive Criminal Law General Conditions Offenses In...
ManiMaran230751
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdfSoftware_Engineering_in_6_Hours_lyst1728638742594.pdf
Software_Engineering_in_6_Hours_lyst1728638742594.pdf
VanshMunjal7
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
危 / HIFLUX Co., Ltd.
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
[HIFLUX] High Pressure Tube Support Catalog 2025
[HIFLUX] High Pressure Tube Support Catalog 2025[HIFLUX] High Pressure Tube Support Catalog 2025
[HIFLUX] High Pressure Tube Support Catalog 2025
危 / HIFLUX Co., Ltd.
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
Influence line diagram for truss in a robust
Influence line diagram for truss in a robustInfluence line diagram for truss in a robust
Influence line diagram for truss in a robust
ParthaSengupta26

Routing to components

  • 3. Directive + Template === Component
  • 4. class Component extends Directive { ... }
  • 5. import { ComponentAnnotation as Component, ViewAnnotation as View, bootstrap import { NgFor } from 'angular2/directives' @Component({ selector: 'things' }) @View({ template: `<div> <h5>A LIST OF THINGS!!!</h5> <ul> <li *ng-for="#thing of things; #i = index" (click)="onClickIt {{thing}} </li> </ul> </div>`,
  • 6. import { bootstrap } from 'angular2/angular2'; ... bootstrap(Things) ... <things></things>
  • 9. $stateProvider .state('report',{ views: { 'filters': { templateUrl: 'report-filters.html', controller: function(){ ... filters view controller ... } }, 'tabledata': { templateUrl: 'report-table.html', controller: function(){ ... tabledata view controller ... } }, 'graph': { templateUrl: 'report-graph.html', controller: function(){ ... graph view controller ... } } }
  • 11. AppController.$routeConfig = [ { path: '/report', components: { filters: 'filters', tableData: 'tableDat ] ... <div class="container"> <div ng-outlet="filters"></div> <div ng-outlet="tableData"></div> <div ng-outlet="graph"></div> </div> @Component({ selector: 'app' }) @View({ template: ` <div class="container"> <router-outlet name="filters"></router-outlet> <router-outlet name="tableData"></router-outlet> <router-outlet name="graph"></router-outlet> </div> `, directives: [RouterOutlet] }) @RouteConfig([ { path: '/report', components: { filters: Filters, tableData: TableData ]) class App { }
  • 13. ANGULAR 1 => ANGULAR 2 MIGRATION