(Go: >> BACK << -|- >> HOME <<)

SlideShare a Scribd company logo
Name of the Speaker : Naveen Pete
Place: Bengaluru
http://www.unicomlearning.com/2016/DevCon/
DevCon 2016 – Bangalore
Date – 30th Nov – 2nd Dec
Introduction to Angular 2
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Agenda
1. Why Library or Framework?
2. Introducing Angular
3. TypeScript
4. Setting up Angular 2
5. Angular 2 Building Blocks
6. Code Walk-thru & Demo
7. Q & A
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
1. Why Library or Framework?
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Web BrowserWeb Server
URL Request to server
Response with Web page & Assets
User clicks on link, new Request
Response with Web page & Assets
HTML JavaScript
Browser loads up
entire web page
HTML JavaScript
Browser loads up
entire web page
Traditional Page Refresh
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Data Binding
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Benefits of Library or Framework
• Abstracts complexities of development
• Increases developer productivity
• Moving the application code forward in the stack
▫ Reduces server load, thus reducing cost
▫ Crowd-sourcing of computational power
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
2. Introducing Angular
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Introducing Angular
• Developed in 2009 by Misko Hevery
• Structural framework for building dynamic web apps
• Front-end SPA, RIA framework
• Build modular, maintainable and testable apps
• Current Release Versions
▫ Angular 1.5.9
▫ Angular 2.2
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Angular Benefits
• Build responsive apps for different platforms
• Helps you organize your code
• Data Binding and Dependency Injection eliminates much of the
manual code
• Decouple DOM manipulation from app logic
▫ Improves testability
• Decouple client side of an app from the server side
▫ Allows reuse
▫ Allows parallel development
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Responsive Page using Angular (or any other framework)
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Two-Way Data Binding
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
3. TypeScript
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
TypeScript
• Superset of JavaScript
• Chosen as main language by Angular 2
• By far most documentation & example-base uses TypeScript
• Why TypeScript?
▫ Strong Typing
 reduces compile-time errors, provides IDE support
▫ Next Gen JS Features
 Modules, Classes, Import, Export, …
▫ Missing JS Features
 Interfaces, Generics, …
Install TypeScript
[sudo] npm install –g typescript
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
4. Setting up Angular 2
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Setting up Angular
• Install Node (https://nodejs.org/en/)
• Install TypeScript – This is optional
• Install Angular CLI (https://cli.angular.io/)
• Create new Angular App
• Start the app
▫ ng serve
 Starts up development server
 Builds the app
> npm install –g typescript
> npm install –g angular-cli
> ng new first-app
> cd first-app
> ng serve
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
5. Angular 2 Building Blocks
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Module
ServiceComponentTemplate
Server
Directive
Pipe
Browser /
View
Router
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Module (NgModule)
• A block of highly related classes
• Organizes an application into cohesive blocks of functionality
• Every app has at least one module, called AppModule
@NgModule({
imports: [module1, module2, ...],
declarations: [
component(s), directive(s), pipe(s), ...
],
exports: [class1, class2, ...],
providers: [service1, service2, ...]
})
export class AppModule{ }
AppModule
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Component
• Encapsulates the template, data and the behavior of a view
• Every app has at least one component, called AppComponent
• Completely decoupled from the DOM
@Component({
selector: ‘rating’,
templateUrl: ‘./rating.component.html’,
styleUrls: [‘./rating.component.css’]
})
export class RatingComponent {
averageRating: number;
setRating(value) {
...
}
}
Creating Component
> ng g c product
AppComponent
HeaderComponent
RecipesComponent
ShoppingListComponent
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Template & Data Binding
• Defines component’s view
• Uses HTML and Angular’s template elements & attributes
• Data Binding
▫ Interpolation
 <h1>{{hero.name}}</h1>
▫ Property binding
 <img [src]=“heroImageUrl”>
▫ Event binding
 <li (click)=“selectHero(hero)”></li>
▫ Two-way data binding
 <input [(ngModel)]="hero.name">
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Template & Data Binding
Examples:
ShoppingListComponent
RecipeItemComponent
RecipeDetailComponent
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Directive
• Helps you to extend HTML to support dynamic behavior
• Transforms the DOM according to instructions given
• Can be built-in or custom
• Two kinds
▫ Structural – alter the layout. E.g. *ngFor, *ngIf
▫ Attribute – alter the appearance or behavior. E.g. ngModel, ngClass
@Directive({
selector: '[appRating]‘
})
export class RatingDirective {
...
}
Creating Custom
Directive
> ng g d rating
ShoppingListComponent
ShoppingListAddComponent
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Service
• Allows organizing and sharing code across an app
▫ AJAX calls
▫ Business rules
▫ Calculations
▫ Share data between components
@Injectable()
export class ProductService {
...
}
Creating Service
> ng g s product
RecipeService
ShoppingListService
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Dependency Injection
• Dependency: An object that can be used (a service)
• Injection: Passing of a dependency to a dependent object so that it
can use it. The client does not need to build the object
• Angular 2 uses constructor injection
@Component({
selector: 'rb-recipe-list',
templateUrl: './recipe-list.component.html‘,
providers: [RecipeService]
})
export class RecipeListComponent implements OnInit {
constructor(private recipeService: RecipeService) { }
}
RecipeListComponent
ShoppingListComponent
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Pipe
• Transforms displayed values within a template
• Does not modify underlying data
• Built-in pipes
▫ CurrencyPipe, DatePipe, JsonPipe, LowerCasePipe, UpperCasePipe
Creating Custom Pipe
> ng g p my-currency
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Router
• Enables navigation from one view to the next as users perform application tasks
• Maps a URL path to a component
• Steps
▫ Define array of routes using ‘Routes’
▫ Register routes with router module using ‘Router.forRoot()’
▫ Add the resulting module to ‘imports’ array of ‘AppModule’
▫ Add <router-outlet> element to the template
▫ Use ‘routerLink’ attribute directive in <a> tag to navigate to a specific route
 <a [routerLink]="['/recipes']">Recipes</a>
app.routing.ts
app.module.ts
app.component.html
header.component.html
recipe-item.component.html
recipe-detail.component.ts
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Server Communication – Angular Http Client
• Communicates with remote servers using HTTP protocol
• Uses browser’s XmlHttpRequest object
• Methods
▫ get()
▫ post()
▫ put()
▫ delete()
• Methods return Observable<Response>
RecipeService
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
6. Code Walk-thru & Demo
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
Recipe Book App
AppComponent
(rb-root)
HeaderComponent
(rb-header)
RecipesComponent
(rb-recipes)
RecipeListComponent
(rb-recipe-list)
RecipeItemComponent
(rb-recipe-item)
RecipeStartComponent
(rb-recipe-start)
RecipeDetailComponent
(rb-recipe-detail)
RecipeEditComponent
(rb-recipe-edit)
ShoppingListComponent
(rb-shopping-list)
ShoppingListAddComponent
(rb-shopping-list-add)
https://github.com/naveen-pete/ng-2 (Project: recipe-book)
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/
7. Q & A
World Conference Next Generation
Testing 2015
Speaker Name: Naveen Pete
Linked In: https://www.linkedin.com/in/naveen-pete
Organized by
UNICOM Trainings & Seminars Pvt. Ltd.
contact@unicomlearning.com
DevCon 2016 – Bangalore
http://www.unicomlearning.com/2016/DevCon/

More Related Content

What's hot

Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
Dhyego Fernando
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
Ravi Mone
 
AngularJS2 / TypeScript / CLI
AngularJS2 / TypeScript / CLIAngularJS2 / TypeScript / CLI
AngularJS2 / TypeScript / CLI
Domenico Rutigliano
 
The productive developer guide to Angular 2
The productive developer guide to Angular 2The productive developer guide to Angular 2
The productive developer guide to Angular 2
Maurice De Beijer [MVP]
 
Tech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new frameworkTech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new framework
Codemotion
 
Express: A Jump-Start
Express: A Jump-StartExpress: A Jump-Start
Express: A Jump-Start
Naveen Pete
 
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
Paweł Żurowski
 
Angular js 2
Angular js 2Angular js 2
Angular js 2
Ran Wahle
 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core concepts
Codemotion
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2
Commit University
 
Angular 2 Crash Course
Angular  2 Crash CourseAngular  2 Crash Course
Angular 2 Crash Course
Elisha Kramer
 
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
Ross Dederer
 
The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5
Johannes Weber
 
Angular 2
Angular 2Angular 2
Angular 2
Nigam Goyal
 
Async patterns in javascript
Async patterns in javascriptAsync patterns in javascript
Async patterns in javascript
Ran Wahle
 
Angular 2
Angular 2Angular 2
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?
jbandi
 
Angular 2... so can I use it now??
Angular 2... so can I use it now??Angular 2... so can I use it now??
Angular 2... so can I use it now??
Laurent Duveau
 
An Overview of Angular 4
An Overview of Angular 4 An Overview of Angular 4
Data Flow Patterns in Angular 2 - Sebastian Müller
Data Flow Patterns in Angular 2 -  Sebastian MüllerData Flow Patterns in Angular 2 -  Sebastian Müller
Data Flow Patterns in Angular 2 - Sebastian Müller
Sebastian Holstein
 

What's hot (20)

Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
 
AngularJS2 / TypeScript / CLI
AngularJS2 / TypeScript / CLIAngularJS2 / TypeScript / CLI
AngularJS2 / TypeScript / CLI
 
The productive developer guide to Angular 2
The productive developer guide to Angular 2The productive developer guide to Angular 2
The productive developer guide to Angular 2
 
Tech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new frameworkTech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new framework
 
Express: A Jump-Start
Express: A Jump-StartExpress: A Jump-Start
Express: A Jump-Start
 
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
 
Angular js 2
Angular js 2Angular js 2
Angular js 2
 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core concepts
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2
 
Angular 2 Crash Course
Angular  2 Crash CourseAngular  2 Crash Course
Angular 2 Crash Course
 
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
 
The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5
 
Angular 2
Angular 2Angular 2
Angular 2
 
Async patterns in javascript
Async patterns in javascriptAsync patterns in javascript
Async patterns in javascript
 
Angular 2
Angular 2Angular 2
Angular 2
 
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?
 
Angular 2... so can I use it now??
Angular 2... so can I use it now??Angular 2... so can I use it now??
Angular 2... so can I use it now??
 
An Overview of Angular 4
An Overview of Angular 4 An Overview of Angular 4
An Overview of Angular 4
 
Data Flow Patterns in Angular 2 - Sebastian Müller
Data Flow Patterns in Angular 2 -  Sebastian MüllerData Flow Patterns in Angular 2 -  Sebastian Müller
Data Flow Patterns in Angular 2 - Sebastian Müller
 

Similar to Introduction to Angular 2

Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
Mallikarjuna G D
 
Angular, the New Angular JS
Angular, the New Angular JSAngular, the New Angular JS
Angular, the New Angular JS
Kenzan
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
TejinderMakkar
 
Angular for rookies MS TechDays 2017
Angular for rookies MS TechDays 2017Angular for rookies MS TechDays 2017
Angular for rookies MS TechDays 2017
Erik van Appeldoorn
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
Yakov Fain
 
Angular js 2.0 beta
Angular js 2.0 betaAngular js 2.0 beta
Angular js 2.0 beta
Nagaraju Sangam
 
Angular
AngularAngular
Angular
sridhiya
 
AngularJS: Service, factory & provider
AngularJS: Service, factory & providerAngularJS: Service, factory & provider
AngularJS: Service, factory & provider
Corley S.r.l.
 
Angular2 & Native Script GDG DevFest 2016
Angular2 & Native Script GDG DevFest 2016Angular2 & Native Script GDG DevFest 2016
Angular2 & Native Script GDG DevFest 2016
Luciano Murruni
 
mean stack
mean stackmean stack
mean stack
michaelaaron25322
 
Angular IO
Angular IOAngular IO
Angular IO
Jennifer Estrada
 
Angular 6 Form Validation with Material
Angular 6 Form Validation with MaterialAngular 6 Form Validation with Material
Angular 6 Form Validation with Material
Malika Munaweera
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
Gaurav Agrawal
 
Front End Development for Back End Developers - Devoxx UK 2017
 Front End Development for Back End Developers - Devoxx UK 2017 Front End Development for Back End Developers - Devoxx UK 2017
Front End Development for Back End Developers - Devoxx UK 2017
Matt Raible
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
Dev_Events
 
Angular meetup 2 2019-08-29
Angular meetup 2   2019-08-29Angular meetup 2   2019-08-29
Angular meetup 2 2019-08-29
Nitin Bhojwani
 
Angular Js Basics
Angular Js BasicsAngular Js Basics
Angular Js Basics
أحمد عبد الوهاب
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
WebStackAcademy
 
Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0
Pece Nikolovski
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
Rolands Krumbergs
 

Similar to Introduction to Angular 2 (20)

Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Angular, the New Angular JS
Angular, the New Angular JSAngular, the New Angular JS
Angular, the New Angular JS
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
 
Angular for rookies MS TechDays 2017
Angular for rookies MS TechDays 2017Angular for rookies MS TechDays 2017
Angular for rookies MS TechDays 2017
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Angular js 2.0 beta
Angular js 2.0 betaAngular js 2.0 beta
Angular js 2.0 beta
 
Angular
AngularAngular
Angular
 
AngularJS: Service, factory & provider
AngularJS: Service, factory & providerAngularJS: Service, factory & provider
AngularJS: Service, factory & provider
 
Angular2 & Native Script GDG DevFest 2016
Angular2 & Native Script GDG DevFest 2016Angular2 & Native Script GDG DevFest 2016
Angular2 & Native Script GDG DevFest 2016
 
mean stack
mean stackmean stack
mean stack
 
Angular IO
Angular IOAngular IO
Angular IO
 
Angular 6 Form Validation with Material
Angular 6 Form Validation with MaterialAngular 6 Form Validation with Material
Angular 6 Form Validation with Material
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Front End Development for Back End Developers - Devoxx UK 2017
 Front End Development for Back End Developers - Devoxx UK 2017 Front End Development for Back End Developers - Devoxx UK 2017
Front End Development for Back End Developers - Devoxx UK 2017
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
 
Angular meetup 2 2019-08-29
Angular meetup 2   2019-08-29Angular meetup 2   2019-08-29
Angular meetup 2 2019-08-29
 
Angular Js Basics
Angular Js BasicsAngular Js Basics
Angular Js Basics
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
 

Recently uploaded

ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
Ortus Solutions, Corp
 
Revolutionizing Task Scheduling in ColdBox
Revolutionizing Task Scheduling in ColdBoxRevolutionizing Task Scheduling in ColdBox
Revolutionizing Task Scheduling in ColdBox
Ortus Solutions, Corp
 
Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?
Ortus Solutions, Corp
 
Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02
williamrobertherman
 
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ... @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
Mona Rathore
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
williamrobertherman
 
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
arvindkumarji156
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 
Web Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox ProWeb Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox Pro
Ortus Solutions, Corp
 
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S... @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
Mona Rathore
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
Hironori Washizaki
 
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeKolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Misti Soneji
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
confluent
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
e-Definers Technology
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
shivamt017
 
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
Ortus Solutions, Corp
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
dachnug51 - HCL Domino Roadmap .pdf
dachnug51 - HCL Domino Roadmap      .pdfdachnug51 - HCL Domino Roadmap      .pdf
dachnug51 - HCL Domino Roadmap .pdf
DNUG e.V.
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
Ortus Solutions, Corp
 

Recently uploaded (20)

ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
 
Revolutionizing Task Scheduling in ColdBox
Revolutionizing Task Scheduling in ColdBoxRevolutionizing Task Scheduling in ColdBox
Revolutionizing Task Scheduling in ColdBox
 
Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?
 
Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02
 
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ... @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
 
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 
Web Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox ProWeb Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox Pro
 
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S... @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
 
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeKolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
 
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
dachnug51 - HCL Domino Roadmap .pdf
dachnug51 - HCL Domino Roadmap      .pdfdachnug51 - HCL Domino Roadmap      .pdf
dachnug51 - HCL Domino Roadmap .pdf
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
 

Introduction to Angular 2

  • 1. Name of the Speaker : Naveen Pete Place: Bengaluru http://www.unicomlearning.com/2016/DevCon/ DevCon 2016 – Bangalore Date – 30th Nov – 2nd Dec Introduction to Angular 2
  • 2. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Agenda 1. Why Library or Framework? 2. Introducing Angular 3. TypeScript 4. Setting up Angular 2 5. Angular 2 Building Blocks 6. Code Walk-thru & Demo 7. Q & A
  • 3. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ 1. Why Library or Framework?
  • 4. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Web BrowserWeb Server URL Request to server Response with Web page & Assets User clicks on link, new Request Response with Web page & Assets HTML JavaScript Browser loads up entire web page HTML JavaScript Browser loads up entire web page Traditional Page Refresh
  • 5. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Data Binding
  • 6. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Benefits of Library or Framework • Abstracts complexities of development • Increases developer productivity • Moving the application code forward in the stack ▫ Reduces server load, thus reducing cost ▫ Crowd-sourcing of computational power
  • 7. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ 2. Introducing Angular
  • 8. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Introducing Angular • Developed in 2009 by Misko Hevery • Structural framework for building dynamic web apps • Front-end SPA, RIA framework • Build modular, maintainable and testable apps • Current Release Versions ▫ Angular 1.5.9 ▫ Angular 2.2
  • 9. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Angular Benefits • Build responsive apps for different platforms • Helps you organize your code • Data Binding and Dependency Injection eliminates much of the manual code • Decouple DOM manipulation from app logic ▫ Improves testability • Decouple client side of an app from the server side ▫ Allows reuse ▫ Allows parallel development
  • 10. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Responsive Page using Angular (or any other framework)
  • 11. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Two-Way Data Binding
  • 12. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ 3. TypeScript
  • 13. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ TypeScript • Superset of JavaScript • Chosen as main language by Angular 2 • By far most documentation & example-base uses TypeScript • Why TypeScript? ▫ Strong Typing  reduces compile-time errors, provides IDE support ▫ Next Gen JS Features  Modules, Classes, Import, Export, … ▫ Missing JS Features  Interfaces, Generics, … Install TypeScript [sudo] npm install –g typescript
  • 14. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ 4. Setting up Angular 2
  • 15. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Setting up Angular • Install Node (https://nodejs.org/en/) • Install TypeScript – This is optional • Install Angular CLI (https://cli.angular.io/) • Create new Angular App • Start the app ▫ ng serve  Starts up development server  Builds the app > npm install –g typescript > npm install –g angular-cli > ng new first-app > cd first-app > ng serve
  • 16. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ 5. Angular 2 Building Blocks
  • 17. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Module ServiceComponentTemplate Server Directive Pipe Browser / View Router
  • 18. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Module (NgModule) • A block of highly related classes • Organizes an application into cohesive blocks of functionality • Every app has at least one module, called AppModule @NgModule({ imports: [module1, module2, ...], declarations: [ component(s), directive(s), pipe(s), ... ], exports: [class1, class2, ...], providers: [service1, service2, ...] }) export class AppModule{ } AppModule
  • 19. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Component • Encapsulates the template, data and the behavior of a view • Every app has at least one component, called AppComponent • Completely decoupled from the DOM @Component({ selector: ‘rating’, templateUrl: ‘./rating.component.html’, styleUrls: [‘./rating.component.css’] }) export class RatingComponent { averageRating: number; setRating(value) { ... } } Creating Component > ng g c product AppComponent HeaderComponent RecipesComponent ShoppingListComponent
  • 20. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Template & Data Binding • Defines component’s view • Uses HTML and Angular’s template elements & attributes • Data Binding ▫ Interpolation  <h1>{{hero.name}}</h1> ▫ Property binding  <img [src]=“heroImageUrl”> ▫ Event binding  <li (click)=“selectHero(hero)”></li> ▫ Two-way data binding  <input [(ngModel)]="hero.name">
  • 21. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Template & Data Binding Examples: ShoppingListComponent RecipeItemComponent RecipeDetailComponent
  • 22. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Directive • Helps you to extend HTML to support dynamic behavior • Transforms the DOM according to instructions given • Can be built-in or custom • Two kinds ▫ Structural – alter the layout. E.g. *ngFor, *ngIf ▫ Attribute – alter the appearance or behavior. E.g. ngModel, ngClass @Directive({ selector: '[appRating]‘ }) export class RatingDirective { ... } Creating Custom Directive > ng g d rating ShoppingListComponent ShoppingListAddComponent
  • 23. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Service • Allows organizing and sharing code across an app ▫ AJAX calls ▫ Business rules ▫ Calculations ▫ Share data between components @Injectable() export class ProductService { ... } Creating Service > ng g s product RecipeService ShoppingListService
  • 24. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Dependency Injection • Dependency: An object that can be used (a service) • Injection: Passing of a dependency to a dependent object so that it can use it. The client does not need to build the object • Angular 2 uses constructor injection @Component({ selector: 'rb-recipe-list', templateUrl: './recipe-list.component.html‘, providers: [RecipeService] }) export class RecipeListComponent implements OnInit { constructor(private recipeService: RecipeService) { } } RecipeListComponent ShoppingListComponent
  • 25. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Pipe • Transforms displayed values within a template • Does not modify underlying data • Built-in pipes ▫ CurrencyPipe, DatePipe, JsonPipe, LowerCasePipe, UpperCasePipe Creating Custom Pipe > ng g p my-currency
  • 26. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Router • Enables navigation from one view to the next as users perform application tasks • Maps a URL path to a component • Steps ▫ Define array of routes using ‘Routes’ ▫ Register routes with router module using ‘Router.forRoot()’ ▫ Add the resulting module to ‘imports’ array of ‘AppModule’ ▫ Add <router-outlet> element to the template ▫ Use ‘routerLink’ attribute directive in <a> tag to navigate to a specific route  <a [routerLink]="['/recipes']">Recipes</a> app.routing.ts app.module.ts app.component.html header.component.html recipe-item.component.html recipe-detail.component.ts
  • 27. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Server Communication – Angular Http Client • Communicates with remote servers using HTTP protocol • Uses browser’s XmlHttpRequest object • Methods ▫ get() ▫ post() ▫ put() ▫ delete() • Methods return Observable<Response> RecipeService
  • 28. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ 6. Code Walk-thru & Demo
  • 29. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ Recipe Book App AppComponent (rb-root) HeaderComponent (rb-header) RecipesComponent (rb-recipes) RecipeListComponent (rb-recipe-list) RecipeItemComponent (rb-recipe-item) RecipeStartComponent (rb-recipe-start) RecipeDetailComponent (rb-recipe-detail) RecipeEditComponent (rb-recipe-edit) ShoppingListComponent (rb-shopping-list) ShoppingListAddComponent (rb-shopping-list-add) https://github.com/naveen-pete/ng-2 (Project: recipe-book)
  • 30. DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/ 7. Q & A
  • 31. World Conference Next Generation Testing 2015 Speaker Name: Naveen Pete Linked In: https://www.linkedin.com/in/naveen-pete Organized by UNICOM Trainings & Seminars Pvt. Ltd. contact@unicomlearning.com DevCon 2016 – Bangalore http://www.unicomlearning.com/2016/DevCon/