SlideShare a Scribd company logo
Angular 2
Base knowledge
Angular 2
• Complete re-write of AngularJS
• Component-based
• Better performance
• No controllers
• Can write apps in TypeScript, Dart, or
JavaScript (ES5 or ES6)
An app is a tree of components
HTML
import {Component} from 'angular2/core';
import {Route, RouteConfig, RouterOutlet} from 'angular2/router';
import HomeComponent from '../home/home';
import NavbarComponent from '../navbar/navbar';
import FooterComponent from '../footer/footer'; import SearchComponent from '../search/search';
import ProductDetailComponent from "../product-detail/product-detail";
@Component({
selector: 'auction-application',
templateUrl: 'app/components/application/application.html',
directives: [ RouterOutlet, NavbarComponent, FooterComponent,
SearchComponent, HomeComponent ]
})
@RouteConfig([
{path: '/', component: HomeComponent, as: 'Home'},
{path: '/products/:id', component: ProductDetailComponent, as: 'ProductDetail'}
])
export default class ApplicationComponent {}
Project Structure
Project Structure
Navigation with Router
HomeComponent
HomeComponent
Looping with *ngFor
A Sample Toolbox
Index.html<!DOCTYPE html>
<html>
<head>
<script src="//npmcdn.com/angular2@2.0.0-beta.7/bundles/angular2-polyfills.js"></script>
<script src="//npmcdn.com/typescript@1.7.5/lib/typescript.js"></script>
<script src="//npmcdn.com/systemjs@0.19.22/dist/system.src.js"></script>
<script src="//npmcdn.com/rxjs@5.0.0-beta.2/bundles/Rx.js"></script>
<script src="//npmcdn.com/angular2@2.0.0-beta.7/bundles/angular2.dev.js"></script>
<script>
System.config({
transpiler: 'typescript',
typescriptOptions: {emitDecoratorMetadata: true}
});
System.import('main.ts');
</script>
</head>
<body>
<hello-world></hello-world>
</body>
</html>
HelloWorldComponent
Angular from CDN
SystemJS
Starting a new project with npm
1. Generate package.json for your project:
npm init
2. Add Angular dependencies to package.json
3. Download dependencies into the dir
node_modules:
npm install
4. Install live-server npm install live-server
package.json
{
"name": "walkthrough5",
"version": "1.0.0",
"description": “A sample package.json for the Angular app”,
"scripts": { "start": "live-server" },
"dependencies": {
"es6-shim": "0.33.13",
"es6-promise": "^3.0.2",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.23",
"zone.js": "0.5.15",
"angular2": "2.0.0-beta.9" },
"devDependencies": {
"live-server": "^0.9.0",
"typescript": "^1.7.5" }
}
Unidirectional Binding
1. From code to template:
<h1>Hello {{ name }}!</h1>
<span [hidden]=“isZipcodeValid”>
Zip code is not valid
</span>
2. From template to code:
<button (click)="placeBid()">Place Bid</button>
<input placeholder= "Product name“
(input)="onInputEvent()">
Two-way Binding
Synchronizing Model and View:
<input [value]="myComponentProperty"
(input)=“onInputEvent($event)>
<input [(ngModel)] = "myComponentProperty">
• https://github.com/angular/angular
• https://angular.io/docs/ts/latest/guide/ngmodule.html
• ng-book 2 Ari Lerner, Felipe Coury, Nate Murray, Carlos
Taborda
• https://yakovfain.com
• https://www.npmjs.com/~angularcore
• https://opencredo.com/a-deep-dive-into-angular-2-0/
• https://vsavkin.com/writing-angular-2-in-typescript-
1fa77c78d8e8#.5kycaxhbu
Angular 2

More Related Content

PDF
Angular 2: core concepts
ODP
Building scalable modular app with Angular2 concept
 
PPTX
What’s new in angular 2
PDF
Angular2 with type script
PDF
Angular 2 - Core Concepts
PPTX
Angular 2.0: Getting ready
PDF
Angular 2 - The Next Framework
Angular 2: core concepts
Building scalable modular app with Angular2 concept
 
What’s new in angular 2
Angular2 with type script
Angular 2 - Core Concepts
Angular 2.0: Getting ready
Angular 2 - The Next Framework

What's hot (20)

PPTX
Introduction to Angular2
PDF
The evolution of Angular 2 @ AngularJS Munich Meetup #5
PDF
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
PPTX
Angular 4 - quick view
PPTX
Angular 2 + TypeScript = true. Let's Play!
PDF
AngularJS 2.0 Jumpstart
PDF
Tech Webinar: Angular 2, Introduction to a new framework
PDF
Angular2 intro
PDF
Introduction to Angular 2
PDF
Introduction to Angular 2
PDF
An Intro to Angular 2
ODP
Introduction to Angular 2
PPTX
AngularJS2 / TypeScript / CLI
PPTX
Talk for DevFest 2021 - GDG Bénin
PPTX
Angular 4 Introduction Tutorial
PPTX
PDF
Adventures with Angular 2
PPTX
Angular js 2
PPTX
Introduction to Angular2
The evolution of Angular 2 @ AngularJS Munich Meetup #5
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Angular 4 - quick view
Angular 2 + TypeScript = true. Let's Play!
AngularJS 2.0 Jumpstart
Tech Webinar: Angular 2, Introduction to a new framework
Angular2 intro
Introduction to Angular 2
Introduction to Angular 2
An Intro to Angular 2
Introduction to Angular 2
AngularJS2 / TypeScript / CLI
Talk for DevFest 2021 - GDG Bénin
Angular 4 Introduction Tutorial
Adventures with Angular 2
Angular js 2
Ad

Similar to Angular 2 (20)

DOCX
Angular2RoutingSetupByShubham
PDF
Commit University - Exploring Angular 2
PPTX
Angular 2 - a New Hope
PPTX
ngNewRouter
PDF
angular fundamentals.pdf angular fundamentals.pdf
PPTX
Peggy angular 2 in meteor
PPTX
Angular 2 Migration - JHipster Meetup 6
PDF
Angular 4 for Java Developers
PDF
Meetup SkillValue - Angular 6 : Bien démarrer son application
PPTX
mean stack
PDF
Angular routing
PPTX
Routing And Navigation
PDF
هیبرید کارا، از رویا تا واقعیت!
PPTX
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
PPTX
Angular2 + rxjs
PDF
[FEConf Korea 2017]Angular 컴포넌트 대화법
PDF
Angular2 workshop
DOCX
Understand routing in angular 2
PDF
What is your money doing?
PPTX
Angular 2.0 Routing and Navigation
Angular2RoutingSetupByShubham
Commit University - Exploring Angular 2
Angular 2 - a New Hope
ngNewRouter
angular fundamentals.pdf angular fundamentals.pdf
Peggy angular 2 in meteor
Angular 2 Migration - JHipster Meetup 6
Angular 4 for Java Developers
Meetup SkillValue - Angular 6 : Bien démarrer son application
mean stack
Angular routing
Routing And Navigation
هیبرید کارا، از رویا تا واقعیت!
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
Angular2 + rxjs
[FEConf Korea 2017]Angular 컴포넌트 대화법
Angular2 workshop
Understand routing in angular 2
What is your money doing?
Angular 2.0 Routing and Navigation
Ad

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Pharma ospi slides which help in ospi learning
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Classroom Observation Tools for Teachers
PPTX
Lesson notes of climatology university.
PPTX
Cell Structure & Organelles in detailed.
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
GDM (1) (1).pptx small presentation for students
Pharma ospi slides which help in ospi learning
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
O7-L3 Supply Chain Operations - ICLT Program
A systematic review of self-coping strategies used by university students to ...
Classroom Observation Tools for Teachers
Lesson notes of climatology university.
Cell Structure & Organelles in detailed.
Module 4: Burden of Disease Tutorial Slides S2 2025
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Final Presentation General Medicine 03-08-2024.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
RMMM.pdf make it easy to upload and study
Microbial disease of the cardiovascular and lymphatic systems
Supply Chain Operations Speaking Notes -ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
human mycosis Human fungal infections are called human mycosis..pptx

Angular 2

  • 2. Angular 2 • Complete re-write of AngularJS • Component-based • Better performance • No controllers • Can write apps in TypeScript, Dart, or JavaScript (ES5 or ES6)
  • 3. An app is a tree of components
  • 5. import {Component} from 'angular2/core'; import {Route, RouteConfig, RouterOutlet} from 'angular2/router'; import HomeComponent from '../home/home'; import NavbarComponent from '../navbar/navbar'; import FooterComponent from '../footer/footer'; import SearchComponent from '../search/search'; import ProductDetailComponent from "../product-detail/product-detail"; @Component({ selector: 'auction-application', templateUrl: 'app/components/application/application.html', directives: [ RouterOutlet, NavbarComponent, FooterComponent, SearchComponent, HomeComponent ] }) @RouteConfig([ {path: '/', component: HomeComponent, as: 'Home'}, {path: '/products/:id', component: ProductDetailComponent, as: 'ProductDetail'} ]) export default class ApplicationComponent {}
  • 13. Index.html<!DOCTYPE html> <html> <head> <script src="//npmcdn.com/angular2@2.0.0-beta.7/bundles/angular2-polyfills.js"></script> <script src="//npmcdn.com/typescript@1.7.5/lib/typescript.js"></script> <script src="//npmcdn.com/systemjs@0.19.22/dist/system.src.js"></script> <script src="//npmcdn.com/rxjs@5.0.0-beta.2/bundles/Rx.js"></script> <script src="//npmcdn.com/angular2@2.0.0-beta.7/bundles/angular2.dev.js"></script> <script> System.config({ transpiler: 'typescript', typescriptOptions: {emitDecoratorMetadata: true} }); System.import('main.ts'); </script> </head> <body> <hello-world></hello-world> </body> </html> HelloWorldComponent Angular from CDN SystemJS
  • 14. Starting a new project with npm 1. Generate package.json for your project: npm init 2. Add Angular dependencies to package.json 3. Download dependencies into the dir node_modules: npm install 4. Install live-server npm install live-server
  • 15. package.json { "name": "walkthrough5", "version": "1.0.0", "description": “A sample package.json for the Angular app”, "scripts": { "start": "live-server" }, "dependencies": { "es6-shim": "0.33.13", "es6-promise": "^3.0.2", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", "systemjs": "0.19.23", "zone.js": "0.5.15", "angular2": "2.0.0-beta.9" }, "devDependencies": { "live-server": "^0.9.0", "typescript": "^1.7.5" } }
  • 16. Unidirectional Binding 1. From code to template: <h1>Hello {{ name }}!</h1> <span [hidden]=“isZipcodeValid”> Zip code is not valid </span> 2. From template to code: <button (click)="placeBid()">Place Bid</button> <input placeholder= "Product name“ (input)="onInputEvent()">
  • 17. Two-way Binding Synchronizing Model and View: <input [value]="myComponentProperty" (input)=“onInputEvent($event)> <input [(ngModel)] = "myComponentProperty">
  • 18. • https://github.com/angular/angular • https://angular.io/docs/ts/latest/guide/ngmodule.html • ng-book 2 Ari Lerner, Felipe Coury, Nate Murray, Carlos Taborda • https://yakovfain.com • https://www.npmjs.com/~angularcore • https://opencredo.com/a-deep-dive-into-angular-2-0/ • https://vsavkin.com/writing-angular-2-in-typescript- 1fa77c78d8e8#.5kycaxhbu