SlideShare a Scribd company logo
ANGULAR 2 PRE-WORKSHOP
Register in Slack “Open Web Uruguay” http://owu.herokuapp.com/
Channel #jsconfuy-angular2
Channel
Requirements Run
● $ ng new music
● $ cd music
1. NodeJS >= 4.0.0
2. Angular CLI
$ npm install -g angular-cli@0.0.30
WHERE
Antel, Guatemala 1075,
Montevideo, Uruguay
Greetings,
ONLINE
Web: https://angular2-jsconf.herokuapp.com/
ANGULAR 2
JSCONF WORKSHOP
with Iran Reyes & Santiago Ferreira
@iranfleitas @san650
Speakers
@matias_delgado @vlavella19
Collaborators
@sebasrodriguez
Angular 2 MVD workshop
Angular 2 MVD workshop
Table of Content
1. Angular 2
2. angular-cli
3. Base template
4. Components and binding
5. Consuming data
6. Routing
7. Services
ANGULAR 2
● Framework JS by Google (back to 7 years ago)
● Closer to Web Standards
● ES5 / ES6 / Typescript / Dart
● Faster, Semantically better, Easy, ...
MUSIC
ANGULAR-CLI
GUIDELINE
● Generators (Blueprints)
● Project structure based on conventions
● Test runner
● Development server
● Addons
● Deploys and other stuff…
ANGULAR-CLI
ANGULAR-CLI
● $ npm install -g angular-cli@0.0.30
● $ ng new music/
● $ cd music/
● $ ng server (en otra consola)
GUIDELINE
● Generators (Blueprints)
● Project structure based on conventions
● Test runner
● Development server
● Addons
● Deploys and other stuff…
BASE TEMPLATE
BASE TEMPLATE
GUIDELINE
● Templates files (.html)
● Global stylesheets
BASE TEMPLATE
1. Copy https://s3-sa-east-1.amazonaws.com/ng-music/templates/music.html
to src/client/app/music.html
2. Add reference to https://ng-music.s3-sa-east-1.amazonaws.com/app.css
in src/client/index.html
<link href="https://ng-music.s3-sa-east-1.amazonaws.com/app.css" rel="stylesheet">
GUIDELINE
● Templates files (.html)
● Global stylesheets
COMPONENTS AND
BINDING
COMPONENTS AND BINDING
GUIDELINE
Components
● Generate components
● Include components on other components
Binding
● one-way bindings using [...] notation
● define events using (...) notation
COMPONENTS AND BINDING
<albums-page> component
1. $ ng generate component albums-page
2. Cut/paste albums-page HTML into music/src/client/app/albums-page/albums-page.html
3. Import AlbumsPage from music/src/client/app/music.ts
4. Register AlbumsPage component as a directive
5. Use <albums-page> component in music/src/client/app/music.html template
COMPONENTS AND BINDING
<album-cover> component
1. $ ng generate component album-cover
2. Cut/paste album-cover HTML into music/src/client/app/album-cover/album-cover.html
3. Import AlbumCover from music/src/client/app/albums-page/albums-page.ts
4. Register AlbumCover component as a directive
5. Use <album-cover> component in music/src/client/app/albums-page/albums-page.html
COMPONENTS AND BINDING
Binding
1. Create dummy album on music/src/client/app/album-cover/album-cover.ts
2. Use [alt]= and [src]= notation to bind attributes
3. Use {{album.artist}} to render text on screen
4. Use (click)= notation to listen to events
GUIDELINE
Components
● Generate components
● Include components on other components
Binding
● one-way bindings using [...] notation
● define events using (...) notation
CONSUMING DATA
CONSUMING DATA
● HTTP Service
● Fetch resources from external source
● Iterate over resources using *ngFor directive
● Know about input and output properties
GUIDELINE
CONSUMING DATA
Fetch all albums
1. Import and register HTTP_PROVIDERS and Http class on AlbumsPage
component
2. Fetch all albums on AlbumsPage constructor
3. Restart server to proxy HTTP requests
4. $ ng server --proxy http://em-ng-workshop.herokuapp.com/
CONSUMING DATA
Render all albums
1. Import and register NgFor directive on AlbumsPage component
import {NgFor} from 'angular2/common';
2. Iterate over all albums on AlbumsPage template
<album-cover *ngFor="#album of albums" [album]="album"></album-cover>
CONSUMING DATA
Use “album” attribute
1. Import Input decorator on AlbumCover component
import {Input,Component} from 'angular2/core';
2. Decorate album property
@Input() album: any;
3. Remove dummy album definition
● HTTP Service
● Fetch resources from external source
● Iterate over resources using *ngFor directive
● Know about input and output properties
GUIDELINE
ROUTING
ROUTING
● @RouteConfig
● <router-outlet>
● [router-link]
GUIDELINE
ROUTING
<tracks-page> component
1. $ ng generate component tracks-page
2. copy https://s3-sa-east-1.amazonaws.com/ng-music/templates/album.html to
music/src/client/app/tracks-page/tracks-page.html
3. Import TracksPage from music/src/client/app/music.ts
4. Remove <albums-page /> component from music/src/client/app/music.html
template
ROUTING
@RouteConfig
1. Register in music/src/app/music.ts components in @RouteConfig
{ path: '/', component: AlbumsPage, name: 'AlbumsPage' },
{ path: '/:id', component: TracksPage, name: 'TracksPage' }
ROUTING
Link to go to /:id
1. Import and register routerLink directive on AlbumCover
import {RouterLink} from 'angular2/router';
2. Update AlbumCover template to add a link to TracksPage
<a [routerLink]="['TracksPage', { id: album.id }]">
3. Remove unneeded (click) event handler
ROUTING
Link to go back to /
1. Update Music template to add a link to AlbumsPage
<a [routerLink]="['AlbumsPage']" class="...">
<span>Albums</span>
</a>
● @RouteConfig
● <router-outlet>
● [router-link]
GUIDELINE
SERVICES
SERVICES
● Application-wide state
● Data store
GUIDELINE
SERVICES
1. $ ng generate service albums-service
1. Move /api/albums query to Albums service
2. Import Http from albums-service/albums-service.ts
3. Also import map: import 'rxjs/add/operator/map';
4. Create a method call getAllAlbums and return the albums
SERVICES
1. Import AlbumsService from albums-page/albums-page.ts
2. Add AlbumsService to the providers in AlbumsPage
3. Inject AlbumsService to the constructor of AlbumsPage
4. Subscribe from AlbumsService for changes
5. Add HTTP_PROVIDERS to music.ts
● Application-wide state
● Data store
GUIDELINE
QUESTIONS?
Angular 2 MVD workshop

More Related Content

PPT
Adjusting the home page layout
chunkayng
 
PDF
Zend Lab
Leo Nguyen
 
PDF
Helmut newton ppt
aidamarti
 
PDF
Upcoming Features on Orkut API by Shishir Birmiwal
Pravin Nirmal
 
PDF
Open Education event - Open Badges in Blackboard
Jisc Scotland
 
PDF
Technology and Website Solutions for Landlords
Bob Randklev
 
PDF
Re-architecting for the 'green' cloud and lower costs. Justin Cormack
Chris Purrington
 
PDF
PCon 2016: Cross-Device Marketing (Anna Petrushkina, Yahoo)
e-dialog GmbH
 
Adjusting the home page layout
chunkayng
 
Zend Lab
Leo Nguyen
 
Helmut newton ppt
aidamarti
 
Upcoming Features on Orkut API by Shishir Birmiwal
Pravin Nirmal
 
Open Education event - Open Badges in Blackboard
Jisc Scotland
 
Technology and Website Solutions for Landlords
Bob Randklev
 
Re-architecting for the 'green' cloud and lower costs. Justin Cormack
Chris Purrington
 
PCon 2016: Cross-Device Marketing (Anna Petrushkina, Yahoo)
e-dialog GmbH
 

Viewers also liked (16)

PPTX
Angular2 workshop
Filip Bruun Bech-Larsen
 
PDF
Angular2 - In Action
Sebastian Pożoga
 
PDF
Angular2 with type script
Ravi Mone
 
PDF
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman
 
PDF
Angular2 - getting-ready
Nir Kaufman
 
PDF
Progressive Web Apps: trick or real magic? - Maurizio Mangione - Codemotion M...
Codemotion
 
PDF
Angular 2 overview
Jesse Warden
 
PPTX
Angular 2 - Better or worse
Vladimir Georgiev
 
PDF
Introduction to Angular 2
Dawid Myslak
 
PDF
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Codemotion
 
PDF
Angular2 workshop
Nir Kaufman
 
PDF
Angular 2 - Core Concepts
Fabio Biondi
 
ODP
Introduction to Angular 2
Knoldus Inc.
 
PDF
Getting Started with Angular 2
FITC
 
Angular2 workshop
Filip Bruun Bech-Larsen
 
Angular2 - In Action
Sebastian Pożoga
 
Angular2 with type script
Ravi Mone
 
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman
 
Angular2 - getting-ready
Nir Kaufman
 
Progressive Web Apps: trick or real magic? - Maurizio Mangione - Codemotion M...
Codemotion
 
Angular 2 overview
Jesse Warden
 
Angular 2 - Better or worse
Vladimir Georgiev
 
Introduction to Angular 2
Dawid Myslak
 
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Codemotion
 
Angular2 workshop
Nir Kaufman
 
Angular 2 - Core Concepts
Fabio Biondi
 
Introduction to Angular 2
Knoldus Inc.
 
Getting Started with Angular 2
FITC
 
Ad

Similar to Angular 2 MVD workshop (20)

PPTX
Building Angular 2.0 applications with TypeScript
MSDEVMTL
 
PDF
The newst new Router for Angular 2 - Talk at @angular_berlin, July 2016
Manfred Steyer
 
PPTX
Angular + Components
Shawn McKay
 
PDF
Front End Development for Back End Developers - vJUG24 2017
Matt Raible
 
PPTX
SAKHIB HUSSAIN PPT 2.pptx
MohanKumar128617
 
PDF
Jlook web ui framework
HongSeong Jeon
 
PDF
Introduction to Angular 2
Naveen Pete
 
PDF
HotPush with Ionic 2 and CodePush
Evan Schultz
 
PDF
Automatic Discovery of Service Metadata for Systems at Scale
Martina Iglesias Fernández
 
PDF
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
Denis_infinum
 
PDF
Infinum Android Talks #04 - How to publish an android archive (.aar) to Maven...
Infinum
 
PPTX
Building ColdFusion And AngularJS Applications
ColdFusionConference
 
PDF
Ride on the Fast Track of Web with Ruby on Rails- Part 2
A.K.M. Ahsrafuzzaman
 
PPTX
Tutorial 1: Your First Science App - Araport Developer Workshop
Vivek Krishnakumar
 
PDF
Angular Notes.pdf
sagarpal60
 
PDF
Angular routing
Sultan Ahmed
 
PDF
Spring Boot
Pei-Tang Huang
 
PPTX
Kubernetes walkthrough
Sangwon Lee
 
PPTX
Peggy angular 2 in meteor
LearningTech
 
PPTX
Alfresco Development Framework Basic
Mario Romano
 
Building Angular 2.0 applications with TypeScript
MSDEVMTL
 
The newst new Router for Angular 2 - Talk at @angular_berlin, July 2016
Manfred Steyer
 
Angular + Components
Shawn McKay
 
Front End Development for Back End Developers - vJUG24 2017
Matt Raible
 
SAKHIB HUSSAIN PPT 2.pptx
MohanKumar128617
 
Jlook web ui framework
HongSeong Jeon
 
Introduction to Angular 2
Naveen Pete
 
HotPush with Ionic 2 and CodePush
Evan Schultz
 
Automatic Discovery of Service Metadata for Systems at Scale
Martina Iglesias Fernández
 
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
Denis_infinum
 
Infinum Android Talks #04 - How to publish an android archive (.aar) to Maven...
Infinum
 
Building ColdFusion And AngularJS Applications
ColdFusionConference
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
A.K.M. Ahsrafuzzaman
 
Tutorial 1: Your First Science App - Araport Developer Workshop
Vivek Krishnakumar
 
Angular Notes.pdf
sagarpal60
 
Angular routing
Sultan Ahmed
 
Spring Boot
Pei-Tang Huang
 
Kubernetes walkthrough
Sangwon Lee
 
Peggy angular 2 in meteor
LearningTech
 
Alfresco Development Framework Basic
Mario Romano
 
Ad

Recently uploaded (20)

PDF
Centralized Business Email Management_ How Admin Controls Boost Efficiency & ...
XgenPlus Technologies
 
PDF
Project English Paja Jara Alejandro.jpdf
AlejandroAlonsoPajaJ
 
PPT
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
PDF
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
PPTX
PPT_M4.3_WORKING WITH SLIDES APPLIED.pptx
MCEAMONVILLAVER
 
PPT
Transformaciones de las funciones elementales.ppt
rirosel211
 
PPTX
AI ad its imp i military life read it ag
ShwetaBharti31
 
PPTX
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
PDF
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
LABUAN 4D
 
PDF
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
PPTX
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
PPTX
Parallel & Concurrent ...
yashpavasiya892
 
PDF
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
PPTX
ENCOR_Chapter_11 - ‌BGP implementation.pptx
nshg93
 
PDF
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
PDF
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
PPTX
how many elements are less than or equal to a mid value and adjusts the searc...
kokiyon104
 
PPTX
Crypto Recovery California Services.pptx
lionsgate network
 
PPTX
Different Generation Of Computers .pptx
divcoder9507
 
PPTX
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
Centralized Business Email Management_ How Admin Controls Boost Efficiency & ...
XgenPlus Technologies
 
Project English Paja Jara Alejandro.jpdf
AlejandroAlonsoPajaJ
 
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
PPT_M4.3_WORKING WITH SLIDES APPLIED.pptx
MCEAMONVILLAVER
 
Transformaciones de las funciones elementales.ppt
rirosel211
 
AI ad its imp i military life read it ag
ShwetaBharti31
 
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
LABUAN 4D
 
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
Parallel & Concurrent ...
yashpavasiya892
 
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
ENCOR_Chapter_11 - ‌BGP implementation.pptx
nshg93
 
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
how many elements are less than or equal to a mid value and adjusts the searc...
kokiyon104
 
Crypto Recovery California Services.pptx
lionsgate network
 
Different Generation Of Computers .pptx
divcoder9507
 
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 

Angular 2 MVD workshop

  • 1. ANGULAR 2 PRE-WORKSHOP Register in Slack “Open Web Uruguay” http://owu.herokuapp.com/ Channel #jsconfuy-angular2 Channel Requirements Run ● $ ng new music ● $ cd music 1. NodeJS >= 4.0.0 2. Angular CLI $ npm install -g [email protected]
  • 2. WHERE Antel, Guatemala 1075, Montevideo, Uruguay Greetings, ONLINE Web: https://angular2-jsconf.herokuapp.com/ ANGULAR 2 JSCONF WORKSHOP with Iran Reyes & Santiago Ferreira
  • 7. Table of Content 1. Angular 2 2. angular-cli 3. Base template 4. Components and binding 5. Consuming data 6. Routing 7. Services
  • 8. ANGULAR 2 ● Framework JS by Google (back to 7 years ago) ● Closer to Web Standards ● ES5 / ES6 / Typescript / Dart ● Faster, Semantically better, Easy, ...
  • 11. GUIDELINE ● Generators (Blueprints) ● Project structure based on conventions ● Test runner ● Development server ● Addons ● Deploys and other stuff…
  • 13. ANGULAR-CLI ● $ npm install -g [email protected] ● $ ng new music/ ● $ cd music/ ● $ ng server (en otra consola)
  • 14. GUIDELINE ● Generators (Blueprints) ● Project structure based on conventions ● Test runner ● Development server ● Addons ● Deploys and other stuff…
  • 17. GUIDELINE ● Templates files (.html) ● Global stylesheets
  • 18. BASE TEMPLATE 1. Copy https://s3-sa-east-1.amazonaws.com/ng-music/templates/music.html to src/client/app/music.html 2. Add reference to https://ng-music.s3-sa-east-1.amazonaws.com/app.css in src/client/index.html <link href="https://ng-music.s3-sa-east-1.amazonaws.com/app.css" rel="stylesheet">
  • 19. GUIDELINE ● Templates files (.html) ● Global stylesheets
  • 22. GUIDELINE Components ● Generate components ● Include components on other components Binding ● one-way bindings using [...] notation ● define events using (...) notation
  • 23. COMPONENTS AND BINDING <albums-page> component 1. $ ng generate component albums-page 2. Cut/paste albums-page HTML into music/src/client/app/albums-page/albums-page.html 3. Import AlbumsPage from music/src/client/app/music.ts 4. Register AlbumsPage component as a directive 5. Use <albums-page> component in music/src/client/app/music.html template
  • 24. COMPONENTS AND BINDING <album-cover> component 1. $ ng generate component album-cover 2. Cut/paste album-cover HTML into music/src/client/app/album-cover/album-cover.html 3. Import AlbumCover from music/src/client/app/albums-page/albums-page.ts 4. Register AlbumCover component as a directive 5. Use <album-cover> component in music/src/client/app/albums-page/albums-page.html
  • 25. COMPONENTS AND BINDING Binding 1. Create dummy album on music/src/client/app/album-cover/album-cover.ts 2. Use [alt]= and [src]= notation to bind attributes 3. Use {{album.artist}} to render text on screen 4. Use (click)= notation to listen to events
  • 26. GUIDELINE Components ● Generate components ● Include components on other components Binding ● one-way bindings using [...] notation ● define events using (...) notation
  • 29. ● HTTP Service ● Fetch resources from external source ● Iterate over resources using *ngFor directive ● Know about input and output properties GUIDELINE
  • 30. CONSUMING DATA Fetch all albums 1. Import and register HTTP_PROVIDERS and Http class on AlbumsPage component 2. Fetch all albums on AlbumsPage constructor 3. Restart server to proxy HTTP requests 4. $ ng server --proxy http://em-ng-workshop.herokuapp.com/
  • 31. CONSUMING DATA Render all albums 1. Import and register NgFor directive on AlbumsPage component import {NgFor} from 'angular2/common'; 2. Iterate over all albums on AlbumsPage template <album-cover *ngFor="#album of albums" [album]="album"></album-cover>
  • 32. CONSUMING DATA Use “album” attribute 1. Import Input decorator on AlbumCover component import {Input,Component} from 'angular2/core'; 2. Decorate album property @Input() album: any; 3. Remove dummy album definition
  • 33. ● HTTP Service ● Fetch resources from external source ● Iterate over resources using *ngFor directive ● Know about input and output properties GUIDELINE
  • 36. ● @RouteConfig ● <router-outlet> ● [router-link] GUIDELINE
  • 37. ROUTING <tracks-page> component 1. $ ng generate component tracks-page 2. copy https://s3-sa-east-1.amazonaws.com/ng-music/templates/album.html to music/src/client/app/tracks-page/tracks-page.html 3. Import TracksPage from music/src/client/app/music.ts 4. Remove <albums-page /> component from music/src/client/app/music.html template
  • 38. ROUTING @RouteConfig 1. Register in music/src/app/music.ts components in @RouteConfig { path: '/', component: AlbumsPage, name: 'AlbumsPage' }, { path: '/:id', component: TracksPage, name: 'TracksPage' }
  • 39. ROUTING Link to go to /:id 1. Import and register routerLink directive on AlbumCover import {RouterLink} from 'angular2/router'; 2. Update AlbumCover template to add a link to TracksPage <a [routerLink]="['TracksPage', { id: album.id }]"> 3. Remove unneeded (click) event handler
  • 40. ROUTING Link to go back to / 1. Update Music template to add a link to AlbumsPage <a [routerLink]="['AlbumsPage']" class="..."> <span>Albums</span> </a>
  • 41. ● @RouteConfig ● <router-outlet> ● [router-link] GUIDELINE
  • 44. ● Application-wide state ● Data store GUIDELINE
  • 45. SERVICES 1. $ ng generate service albums-service 1. Move /api/albums query to Albums service 2. Import Http from albums-service/albums-service.ts 3. Also import map: import 'rxjs/add/operator/map'; 4. Create a method call getAllAlbums and return the albums
  • 46. SERVICES 1. Import AlbumsService from albums-page/albums-page.ts 2. Add AlbumsService to the providers in AlbumsPage 3. Inject AlbumsService to the constructor of AlbumsPage 4. Subscribe from AlbumsService for changes 5. Add HTTP_PROVIDERS to music.ts
  • 47. ● Application-wide state ● Data store GUIDELINE