SlideShare a Scribd company logo
1 of 17
Angular 2
THE BASIC BUILDING BLOCKS OF ANGULAR 2 APPLICATIONS
OVERVIEW
 Angular 2 is a framework to help us build client applications in HTML and
either JavaScript or a language (like Dart or TypeScript).
 With Angular, we write applications by composing
 HTML templates with Angularized markup,
 writing component classes to manage those templates,
 adding application logic in services,
 and handing the top root component to Angular's bootstrapper.
Building blocks
 An Angular 2 for Dart application rests on seven main building blocks:
1. Components
2. Metadata
3. Templates
4. Data binding
5. Directives
6. Services
7. Dependency injection
ARCHITECTURE
Components
A component controls a patch of screen real estate that we could call a view
class HeroListComponent {
List<Hero> heroes;
Hero selectedHero;
HeroListComponent(HeroService heroService) {
heroes = heroService.getHeroes();
}
selectHero(Hero hero) {
selectedHero = hero;
}
}
Templates
We define a component's view with its companion template. A template is a
form of HTML that tells Angular how to render the component
<h2>Hero List</h2>
<div *ngFor="let hero of heroes"
(click)="selectHero(hero)">
{{hero.name}}
</div>
<hero-detail *ngIf="selectedHero != null"
[hero]="selectedHero"></hero-detail>
Component Tree
Metadata
Metadata tells Angular how to process a class.
@Component(
selector: 'hero-list',
templateUrl: 'hero_list_component.html',
styleUrls: const ['hero_list_component.css'],
directives: const [HeroDetailComponent],
providers: const [HeroService]
)
class HeroListComponent { ... }
 At runtime, Angular discovers the metadata specified by
the @Component annotation. That's how Angular learns
how to do "the right thing".
 The template, metadata, and component together
describe the view.
 We apply other metadata annotations in a similar fashion
to guide Angular behavior. @Injectable, @Input,
@Output, and @RouterConfig are a few of the more
popular annotations we'll master as our Angular
knowledge grows.
At runtime, Angular discovers the metadata specified by the @Component annotation. That's how Angular learns how to do "the right thing".
The architectural takeaway is that we must add metadata to our
code so that Angular knows what to do.
Data binding
Without a framework, we would be responsible for pushing data values into
the HTML controls and turning user responses into actions and value updates.
Angular supports data binding, a mechanism for
coordinating parts of a template with parts of a
component. We add binding markup to the
template HTML to tell Angular how to connect
both sides.
There are four forms of data binding syntax. Each
form has a direction — to the DOM, from the
DOM, or in both directions — as indicated by the
arrows in the diagram.
<div ... >{{hero.name}}</div> String Interpolation
DOM  Component
The {{hero.name}} Interpolation displays the
component's hero.name property value within
the <div> tags.
<hero-detail ...
[hero]="selectedHero"></hero-
detail>
Property Binding
DOM  Component
The [hero] property binding passes
the value of selectedHero from the
parent
<div ...
(click)="selectHero(hero)">...</div>
Event Binding
DOM  Component
The (click) event binding calls the
component's selectHero method
when the user clicks a hero's name.
<input
[(ngModel)]="hero.name"></div>
Two-way data binding
DOM  Component
Important fourth form that
combines property and event
binding in a single notation, using
the ngModel directive
Two-way data binding
Data binding is also important for communication between parent and child
components
Directives
A directive is a class with directive metadata. In Dart we apply the @Directive
annotation to attach metadata to the class.
 A component is a directive-with-a-template; a
@Component annotation is actually a
@Directive annotation extended with
template-oriented features.
 Two other kinds of directives exist: structural
and attribute directives.
 Structural directives alter layout by adding,
removing, and replacing elements in DOM.
 Attribute directives alter the appearance or
behavior of an existing element.
Structural Directives
<div *ngFor="let hero of heroes">
<h1> {{hero.name}}</h1>
</div>
<hero-detail *ngIf="selectedHero != null"
>
<h1> {{hero.name}}</h1>
</hero-detail>
Attribute Directives
<div>
<input [(ngModel)]="hero.name">
</div>
Services
Services is a broad category encompassing any value, function, or feature that
our application needs.
 Almost anything can be a service. A service is
typically a class with a narrow, well-defined
purpose. It should do something specific and
do it well.
 A component's job is to enable the user
experience and nothing more. It mediates
between the view (rendered by the template)
and the application logic (which often includes
some notion of a model).
Dependency injection
Dependency injection is a way to supply a new instance of a class with the
fully-formed dependencies it requires.
 Most dependencies are services. Angular uses
dependency injection to provide new
components with the services they need.
 Angular can tell which services a component
needs by looking at the types of its constructor
parameters.
 When Angular creates a component, it first
asks an injector for the services that the
component requires.
Angular features and services
 Animations:
 Bootstrap:
 Change detection:
 Component router:
 Events:
 Forms:
 HTTP:
 Lifecycle hooks:
 Pipes:

More Related Content

What's hot

AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation Phan Tuan
 
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0Oleksii Prohonnyi
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2Dor Moshe
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questionsGoa App
 
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 2Maurice De Beijer [MVP]
 
Angular2 with TypeScript
Angular2 with TypeScript Angular2 with TypeScript
Angular2 with TypeScript Rohit Bishnoi
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency InjectionNir Kaufman
 
Microservices in a netshell
Microservices in a netshellMicroservices in a netshell
Microservices in a netshellKnoldus Inc.
 
An introduction to Angular2
An introduction to Angular2 An introduction to Angular2
An introduction to Angular2 Apptension
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersOswald Campesato
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - ServicesNir Kaufman
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training Patrick Schroeder
 
Services Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJSServices Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJSSumanth krishna
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScriptAhmed El-Kady
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSKnoldus Inc.
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Naveen Pete
 
Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Ahmed Moawad
 

What's hot (20)

AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0
 
AngularJS 2.0
AngularJS 2.0AngularJS 2.0
AngularJS 2.0
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
 
React render props
React render propsReact render props
React render props
 
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
 
Angular2 with TypeScript
Angular2 with TypeScript Angular2 with TypeScript
Angular2 with TypeScript
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
Microservices in a netshell
Microservices in a netshellMicroservices in a netshell
Microservices in a netshell
 
An introduction to Angular2
An introduction to Angular2 An introduction to Angular2
An introduction to Angular2
 
React js
React jsReact js
React js
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - Services
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training
 
Services Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJSServices Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJS
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1
 

Viewers also liked

Introdução a linguagem de programação Lua
Introdução a linguagem de programação LuaIntrodução a linguagem de programação Lua
Introdução a linguagem de programação LuaLeonardo Soares
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Dawid Myslak
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introductionJonathan Holloway
 
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...Matt Raible
 
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017Matt Raible
 
Migrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipsterMigrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipsterLazaro Prates Junior
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!Jakub Kubrynski
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017Matt Raible
 
Polymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in RealtimePolymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in RealtimeJuarez Filho
 
The Beautiful Simplicity of ES2015
The Beautiful Simplicity of ES2015The Beautiful Simplicity of ES2015
The Beautiful Simplicity of ES2015Brandon Belvin
 
Apresentação Google I/O Extended Vitória
Apresentação Google I/O Extended VitóriaApresentação Google I/O Extended Vitória
Apresentação Google I/O Extended VitóriaFabiano Monte
 

Viewers also liked (20)

Introdução a linguagem de programação Lua
Introdução a linguagem de programação LuaIntrodução a linguagem de programação Lua
Introdução a linguagem de programação Lua
 
Angular 2
Angular 2Angular 2
Angular 2
 
GDG Angular 2
GDG Angular 2GDG Angular 2
GDG Angular 2
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Depuração de software
Depuração de softwareDepuração de software
Depuração de software
 
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
 
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
 
Migrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipsterMigrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipster
 
JHipster
JHipsterJHipster
JHipster
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
O futuro do Android
O futuro do AndroidO futuro do Android
O futuro do Android
 
Polymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in RealtimePolymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in Realtime
 
The Beautiful Simplicity of ES2015
The Beautiful Simplicity of ES2015The Beautiful Simplicity of ES2015
The Beautiful Simplicity of ES2015
 
Angular js gtg-27feb2013
Angular js gtg-27feb2013Angular js gtg-27feb2013
Angular js gtg-27feb2013
 
Web components
Web componentsWeb components
Web components
 
Apresentação Google I/O Extended Vitória
Apresentação Google I/O Extended VitóriaApresentação Google I/O Extended Vitória
Apresentação Google I/O Extended Vitória
 
Polymer Starter Kit
Polymer Starter KitPolymer Starter Kit
Polymer Starter Kit
 

Similar to Angular 2

Similar to Angular 2 (20)

Angular2
Angular2Angular2
Angular2
 
Directives
DirectivesDirectives
Directives
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
 
Angular Components.pptx
Angular Components.pptxAngular Components.pptx
Angular Components.pptx
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
Angular Directive.pptx
Angular Directive.pptxAngular Directive.pptx
Angular Directive.pptx
 
Angular2 and You
Angular2 and YouAngular2 and You
Angular2 and You
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
17612235.ppt
17612235.ppt17612235.ppt
17612235.ppt
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
 
Angular js
Angular jsAngular js
Angular js
 
Directives.pptx
Directives.pptxDirectives.pptx
Directives.pptx
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
 
Html
HtmlHtml
Html
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
Html5 tutorial
Html5 tutorialHtml5 tutorial
Html5 tutorial
 
Html5 - Tutorial
Html5 - TutorialHtml5 - Tutorial
Html5 - Tutorial
 
Leveling up with AngularJS
Leveling up with AngularJSLeveling up with AngularJS
Leveling up with AngularJS
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to server
 
Web components
Web componentsWeb components
Web components
 

Recently uploaded

UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 

Recently uploaded (20)

UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 

Angular 2

  • 1. Angular 2 THE BASIC BUILDING BLOCKS OF ANGULAR 2 APPLICATIONS
  • 2. OVERVIEW  Angular 2 is a framework to help us build client applications in HTML and either JavaScript or a language (like Dart or TypeScript).  With Angular, we write applications by composing  HTML templates with Angularized markup,  writing component classes to manage those templates,  adding application logic in services,  and handing the top root component to Angular's bootstrapper.
  • 3. Building blocks  An Angular 2 for Dart application rests on seven main building blocks: 1. Components 2. Metadata 3. Templates 4. Data binding 5. Directives 6. Services 7. Dependency injection
  • 5. Components A component controls a patch of screen real estate that we could call a view class HeroListComponent { List<Hero> heroes; Hero selectedHero; HeroListComponent(HeroService heroService) { heroes = heroService.getHeroes(); } selectHero(Hero hero) { selectedHero = hero; } }
  • 6. Templates We define a component's view with its companion template. A template is a form of HTML that tells Angular how to render the component <h2>Hero List</h2> <div *ngFor="let hero of heroes" (click)="selectHero(hero)"> {{hero.name}} </div> <hero-detail *ngIf="selectedHero != null" [hero]="selectedHero"></hero-detail>
  • 8. Metadata Metadata tells Angular how to process a class. @Component( selector: 'hero-list', templateUrl: 'hero_list_component.html', styleUrls: const ['hero_list_component.css'], directives: const [HeroDetailComponent], providers: const [HeroService] ) class HeroListComponent { ... }
  • 9.  At runtime, Angular discovers the metadata specified by the @Component annotation. That's how Angular learns how to do "the right thing".  The template, metadata, and component together describe the view.  We apply other metadata annotations in a similar fashion to guide Angular behavior. @Injectable, @Input, @Output, and @RouterConfig are a few of the more popular annotations we'll master as our Angular knowledge grows. At runtime, Angular discovers the metadata specified by the @Component annotation. That's how Angular learns how to do "the right thing". The architectural takeaway is that we must add metadata to our code so that Angular knows what to do.
  • 10. Data binding Without a framework, we would be responsible for pushing data values into the HTML controls and turning user responses into actions and value updates. Angular supports data binding, a mechanism for coordinating parts of a template with parts of a component. We add binding markup to the template HTML to tell Angular how to connect both sides. There are four forms of data binding syntax. Each form has a direction — to the DOM, from the DOM, or in both directions — as indicated by the arrows in the diagram.
  • 11. <div ... >{{hero.name}}</div> String Interpolation DOM  Component The {{hero.name}} Interpolation displays the component's hero.name property value within the <div> tags. <hero-detail ... [hero]="selectedHero"></hero- detail> Property Binding DOM  Component The [hero] property binding passes the value of selectedHero from the parent <div ... (click)="selectHero(hero)">...</div> Event Binding DOM  Component The (click) event binding calls the component's selectHero method when the user clicks a hero's name. <input [(ngModel)]="hero.name"></div> Two-way data binding DOM  Component Important fourth form that combines property and event binding in a single notation, using the ngModel directive
  • 12. Two-way data binding Data binding is also important for communication between parent and child components
  • 13. Directives A directive is a class with directive metadata. In Dart we apply the @Directive annotation to attach metadata to the class.  A component is a directive-with-a-template; a @Component annotation is actually a @Directive annotation extended with template-oriented features.  Two other kinds of directives exist: structural and attribute directives.  Structural directives alter layout by adding, removing, and replacing elements in DOM.  Attribute directives alter the appearance or behavior of an existing element.
  • 14. Structural Directives <div *ngFor="let hero of heroes"> <h1> {{hero.name}}</h1> </div> <hero-detail *ngIf="selectedHero != null" > <h1> {{hero.name}}</h1> </hero-detail> Attribute Directives <div> <input [(ngModel)]="hero.name"> </div>
  • 15. Services Services is a broad category encompassing any value, function, or feature that our application needs.  Almost anything can be a service. A service is typically a class with a narrow, well-defined purpose. It should do something specific and do it well.  A component's job is to enable the user experience and nothing more. It mediates between the view (rendered by the template) and the application logic (which often includes some notion of a model).
  • 16. Dependency injection Dependency injection is a way to supply a new instance of a class with the fully-formed dependencies it requires.  Most dependencies are services. Angular uses dependency injection to provide new components with the services they need.  Angular can tell which services a component needs by looking at the types of its constructor parameters.  When Angular creates a component, it first asks an injector for the services that the component requires.
  • 17. Angular features and services  Animations:  Bootstrap:  Change detection:  Component router:  Events:  Forms:  HTTP:  Lifecycle hooks:  Pipes: