SlideShare a Scribd company logo
Angular 2
Loiane Groner
github.com/loiane
loiane.com
loiane.training
@loiane
overview
in 60 minutes
• 10+ XP IT
• Java, JavaScript, Sencha, Angular
Phonegap/Ionic
• Blog: http://loiane.com
• Courses (pt-br): http://loiane.training
• My books:
!==
Angular 2 overview in 60 minutes
Angular 2 overview in 60 minutes
Angular 2 overview in 60 minutes
TYPESCRIPT
TypeScript
ECMAScript 6
ECMAScript 5
ES 2015
November 2009
my-script.ts
transpiler
my-script.js
ES5
Classes and Modules
ECMAScript 7
ES 2016
Decorators and Async
data type, interfaces
WHAT WE NEED TO INSTALL
https://nodejs.org
TYPESCRIPT
https://www.typescriptlang.org/
TYPESCRIPT
$ npm install -g typescript
$ sudo npm install -g typescript
MAC OR LINUX
> npm install -g angular-cli
> ng new my-project
> cd my-project
> ng serve
COMPONENTS DIRECTIVES
ROUTINGSERVICES
TEMPLATE
DATA BINDINGDEPENDENCY
INJECTION
MODULES
Main Blocks
COMPONENT
{…}
TEMPLATE
<..>
COMPONENT
{…}
TEMPLATE
<..>
Property
Binding
COMPONENT
{…}
TEMPLATE
<..>
Property
Binding
Event
Binding
COMPONENT
{…}
TEMPLATE
<..>
DIRECTIVES
{..}
Property
Binding
Event
Binding
COMPONENT
{…}
TEMPLATE
<..>
DIRECTIVES
{..}
SERVICES
SERVICE A
SERVICE B
Property
Binding
Event
Binding
COMPONENT
{…}
TEMPLATE
<..>
DIRECTIVES
{..}
SERVICES
SERVICE A
SERVICE B MODULE X
MODULE A
MODULE B
Property
Binding
Event
Binding
Modules
Angular 2 overview in 60 minutes
ES 2015 class
imports
Angular 2 overview in 60 minutes
Declaration of classes we
want to use in the project (Components,
Directives, Pipes)
Declaration of classes we
want to use in the project (Components,
Directives, Pipes)
Other module
imports we want to use within this
module
Declaration of classes we
want to use in the project (Components,
Directives, Pipes)
Other module
imports we want to use within this
module
Project’s main component
Angular 2 overview in 60 minutes
We can also create Feature
Modules to help us
organizing the project
We can also create Feature
Modules to help us
organizing the project
Service providers
Admin
Users
Entitlements
Shared/Common
FormValidations
Pipes
Products
ProductsContainer
ProductsList
ProductDetail
ProductForm
Clients
ClientsContainer
ClientsList
ClientDetails
ClientForm
Sales
SalesContainer
SalesLists
SalesDetails
SalesForm
ProductSalesForm
Reports
DashboardReport
ClientsReport
SearchClientsReport
ProductsReport
SearchProductsReport
SalesReport
SearchSalesReport
ExcelExporter
PDFExporter
Root
AppComponent
NavBar
Menu
Components
Step 1: Component creation
Step 1: Component creation
Step 1: Component creation
Step 1: Component creation
[Web Components]
Name of the HTML tag for
this Component
Step 2: Import and declare the Component in the Module
Step 3: Add the HTML tag in another Component
Step 3: Add the HTML tag in another Component
Templates
The Template contains the HTML that will be rendered
We can also declare it in a separate file
We can also declare it in a separate file
Data
Binding
#1: Interpolation
#1: Interpolation
#2: Property binding
#2: Property binding
The 3 options above have
the same output
#3: Event binding
#3: Event binding
Event that we
will listen to
#3: Event binding
Event that we
will listen to
Method/
Function that will be
executed
#3: Event binding
Event that we
will listen to
Method/
Function that will be
executed
How to maintain the template
and components updated?
How to maintain the template
and components updated?
How to maintain the template
and components updated?
Property binding +
event binding
How to maintain the template
and components updated?
#4: Model Binding (two-way data-binding)
#4: Model Binding (two-way data-binding)
#4: Model Binding (two-way data-binding)
Two-way
data binding with
NgModel
Directives
TEXT
DIRECTIVE TYPES
STRUCTURAL DIRECTIVES
Interact with the view and
modify the DOM structure and/
or HTML code
*ngFor
*ngIf
TEXT
DIRECTIVE TYPES
STRUCTURAL DIRECTIVES
Interact with the view and
modify the DOM structure and/
or HTML code
*ngFor
*ngIf
ATRIBUTE DIRECTIVES
Interact with the element where
the directive was applied
ng-class
ng-style
Conditional If: JavaScript
Directive *ngIf
for loop: JavaScript
Directive *ngFor
Class property binding
Directive ngClass
And how components can communicate
between themselves?
Parent component <-> child component?
@Input(): Parent Component -> Child Component
@Input(): Parent Component -> Child Component
@Input(): Parent Component -> Child Component
We use the decorator @Input in the atributes we
want to expose to the parent Component
@Output(): Child Component -> Parent Component
@Output(): Child Component -> Parent Component
We emit a
value/event to the parent
component
With @Output we can also listen to custom events
With @Output we can also listen to custom events
We can listen
to the custom event
(@Output)
With @Output we can also listen to custom events
We can listen
to the custom event
(@Output)
We can also receive
the custom value
Services
Step 1: Simply create a class with methods!
Step 1: Simply create a class with methods!
Dependency
Injection
Step 2: Decorate!
Step 2: Decorate!
Don’t forget to
import the decorator
Step 3: Import and declare the service
provider in the module (or component)
Step 3: Import and declare the service
provider in the module (or component)
Don’t forget to
import the service
Step 4: Import and inject the service in the Component’s class
constructor
Step 4: Import and inject the service in the Component’s class
constructor
Don’t forget to
import the service
Angular 2 overview in 60 minutes
Step 1: Import and inject the Http class
Step 1: Import and inject the Http class
Import
Don’t forget to import the HttpModule in the Module as well
Don’t forget to import the HttpModule in the Module as well
We need
to import the Http
Module
Then, we can use the get, post, put and
delete methods!
Restful CRUD
Angular 2 overview in 60 minutes
Manipulating data from server!
Manipulating data from server!
Async data streams:
.do
.map
.filter
.when
.add
Manipulating data from server!
Async data streams:
.do
.map
.filter
.when
.add
Reactive programming
In the Component we can subscribe to changes - Observables
Routing
Step 1: app.routing.ts
Step 1: app.routing.ts
Step 1: app.routing.ts
Step 1: app.routing.ts
Step 2: Import the routes in the app.module
We need to import
the routes
Step 3: Add the tag router-outlet in your main component
Step 4: Add the router links in the projects
Organizing the
routes
Users Modules: create file users.routing.ts
We cannot forget to import it in the module as well
We can also pass parameters to the route
And to get the parameters in the component…
And to get the parameters in the component…
We cannot forget to inject the ActivatedRoute in the component
constructor
Child Routes
Step 1: Declare parent route and its children
Step 1: Declare parent route and its children
Step 2: we also need a router-outlet in the parent route
component
Step 2: we also need a router-outlet in the parent route
component
Guards:
canActivate
canDeactivate
Step 1: Add the route guard
Step 1: Add the route guard
Step 2: create a service that contains the required programming
logic (is logged in, has entitlements)
Step 2: create a service that contains the required programming
logic (is logged in, has entitlements)
Step 2: create a service that contains the required programming
logic (is logged in, has entitlements)
Step 2: create a service that contains the required programming
logic (is logged in, has entitlements)
Step 3: Provide the service so we can use it as a route guard
Step 3: Provide the service so we can use it as a route guard
and there is more!
Pipes
Decorator @Pipe
Using a pipe: | pipeName
Forms
Angular 2 overview in 60 minutes
2 TYPES OF FORMS
•Data-driven (reactive form)
•Validations in the Component
•Template driven
•Validation in the form template
Template-driven
Template-driven
Template-driven
Template-driven
Very important!
Template-driven
Template-driven
Template-driven
Template-driven
Template-driven
Template-driven
Template-driven
Template-driven
Super hiper mega
importante!
Local variable to
reference in the validation
Data-driven
Data-driven
Data-driven
Very important #1
Data-driven
Data-driven
Data-driven
Very important #2
Data-driven
Data-driven
Data-driven
Data-driven
> npm install -g angular-cli
> ng new meu-projeto
> cd meu-projeto
> ng serve
ANGULAR CLI: GENERATING COMPONENTS
> cd myProject
> ng generate component hello-world
> ng g component hello-world
ANGULAR CLI: GENERATING COMPONENTS
Naming conventions
hello-world.component.ts
Words separates by “-“
dot
“component" -> indicates that is a Component
dot
ts -> TypeScript extension
Naming conventions
export class HelloWorldComponent {}
hello-world.component.ts
Naming conventions
export class HelloWorldComponent {}
hello-world.component.ts
The same applies to a service.ts,
pipe.ts, directive.ts, etc
Angular 2 overview in 60 minutes
Angular 2 overview in 60 minutes
Tips for
bug
projects
Lazy loading +
modules
Routes:
loadChildren
Routes:
loadChildren
Loading the applications
Loading the module
Ahead of Time
Compilation
PROJECT DEVELOPMENT WITH ANGULAR 2 + TYPESCRIPT
PROJECT COMPILATION WITH TSC (TS COMPILER)
BUNDLING
MINIFICATION
DEPLOY
“Normal" compilation process
DOWNLOAD OF JAVASCRIPT FILES
ANGULAR 2 BOOTSTRAP
REAL TIME COMPILATION
APPLICATION IS RENDERED
PROJECT DEVELOPMENT WITH ANGULAR 2 + TYPESCRIPT
PROJECT COMPILATION WITH TSC (TS COMPILER)
BUNDLING
MINIFICATION
DEPLOY
COMPILATION OF CODE AND TEMPLATES TO TS
COMPILATION FROM TS TO JS
Aot compilation process
DOWNLOAD OF JAVASCRIPT FILES
ANGULAR 2 BOOTSTRAP
APPLICATION IS RENDERED
ANGULAR CLI: NG SERVE OR BUILD —AOT
> cd myProject
> ng serve —-aot
> ng build —-aot
•https://github.com/loiane/angular2-pokedex
•https://github.com/loiane/angular2-crud-rest
•https://github.com/loiane/angular2-crud-auth-routing
Angular 2 overview in 60 minutes
http://loiane.com
twitter.com/loiane
https://github.com/loiane
youtube.com/loianegroner
http://loiane.training

More Related Content

PPTX
Angular 14.pptx
PPT
Angular 8
PPTX
Angular 9
PDF
Angular - Chapter 1 - Introduction
PPTX
Introduction to Angularjs
PDF
Angular 11
PPTX
Introduction to angular with a simple but complete project
PDF
Angular
Angular 14.pptx
Angular 8
Angular 9
Angular - Chapter 1 - Introduction
Introduction to Angularjs
Angular 11
Introduction to angular with a simple but complete project
Angular

What's hot (20)

PPTX
Python: Common Design Patterns
PPTX
Control flow statements in java
PPTX
Overloading and overriding in vb.net
PPT
Mysql Ppt
PPTX
Angular Directives
PPTX
Angularjs PPT
PPTX
django Forms in a Web API World
PPTX
PPT
MYSQL.ppt
PPTX
jQuery
PDF
Angular Notes.pdf
PPTX
Oop’s Concept and its Real Life Applications
PDF
Angular - Chapter 7 - HTTP Services
ODP
Routing & Navigating Pages in Angular 2
PDF
Angular 2 Essential Training
PDF
react redux.pdf
PPTX
Angular js PPT
PPTX
Sharing Data Between Angular Components
PDF
Angular développer des applications .pdf
PPTX
Laravel Tutorial PPT
Python: Common Design Patterns
Control flow statements in java
Overloading and overriding in vb.net
Mysql Ppt
Angular Directives
Angularjs PPT
django Forms in a Web API World
MYSQL.ppt
jQuery
Angular Notes.pdf
Oop’s Concept and its Real Life Applications
Angular - Chapter 7 - HTTP Services
Routing & Navigating Pages in Angular 2
Angular 2 Essential Training
react redux.pdf
Angular js PPT
Sharing Data Between Angular Components
Angular développer des applications .pdf
Laravel Tutorial PPT
Ad

Viewers also liked (20)

PDF
Devfest Cerrado: Angular 2
PDF
Campus Party Brasil 2017: Angular 2 #cpbr10
PDF
Introducao ao Ionic 2 na pratica
PDF
Angular 2
PDF
Angular 2 em 60 minutos
PDF
Conquistando seu lugar ao sol
PDF
Ionic 2 na pratica!
PDF
DevFest BH: Ionic 2
PPTX
Tutorial do app e o divulgador
PDF
DevFest Nordeste: Ionic 2
PDF
Mobile Summit Brazil: Ionic 2
PDF
Angular 2
PDF
TDC SP 2016: Ionic 2
PDF
Exercicios Filas (Queues) - Estruturas de dados e algoritmos com Java
PDF
Open Source Mobile Experience: Ionic 2
PDF
[Curso Java Basico] Exercicios Aula 24
PPSX
Oficina App Inventor
PDF
Novidades Angular 4.x e CLI
PDF
7 Tips to Beautiful PowerPoint by @itseugenec
PDF
Visual Design with Data
Devfest Cerrado: Angular 2
Campus Party Brasil 2017: Angular 2 #cpbr10
Introducao ao Ionic 2 na pratica
Angular 2
Angular 2 em 60 minutos
Conquistando seu lugar ao sol
Ionic 2 na pratica!
DevFest BH: Ionic 2
Tutorial do app e o divulgador
DevFest Nordeste: Ionic 2
Mobile Summit Brazil: Ionic 2
Angular 2
TDC SP 2016: Ionic 2
Exercicios Filas (Queues) - Estruturas de dados e algoritmos com Java
Open Source Mobile Experience: Ionic 2
[Curso Java Basico] Exercicios Aula 24
Oficina App Inventor
Novidades Angular 4.x e CLI
7 Tips to Beautiful PowerPoint by @itseugenec
Visual Design with Data
Ad

Similar to Angular 2 overview in 60 minutes (20)

PPTX
Presentation on angular 5
PDF
better-apps-angular-2-day1.pdf and home
PPTX
Angular2 + rxjs
PDF
Angular training-course-syllabus
PDF
Angular2 with type script
PPTX
Fly High With Angular - How to build an app using Angular
PDF
Angular 2 introduction
PDF
Angular2 with TypeScript
PPT
17612235.ppt
PDF
Angular for Java Enterprise Developers: Oracle Code One 2018
PDF
Angular js
PDF
Angular js
PDF
Angular training-course-syllabus
PPTX
Introduction to angular | Concepts and Environment setup
PPTX
yrs of IT experience in enterprise programming
PPTX
Angular 18 course for begineers and experienced
PPTX
An afternoon with angular 2
PPTX
Building a TV show with Angular, Bootstrap, and Web Services
PPTX
Angularj2.0
Presentation on angular 5
better-apps-angular-2-day1.pdf and home
Angular2 + rxjs
Angular training-course-syllabus
Angular2 with type script
Fly High With Angular - How to build an app using Angular
Angular 2 introduction
Angular2 with TypeScript
17612235.ppt
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular js
Angular js
Angular training-course-syllabus
Introduction to angular | Concepts and Environment setup
yrs of IT experience in enterprise programming
Angular 18 course for begineers and experienced
An afternoon with angular 2
Building a TV show with Angular, Bootstrap, and Web Services
Angularj2.0

Recently uploaded (20)

PDF
Why Endpoint Security Is Critical in a Remote Work Era?
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
REPORT: Heating appliances market in Poland 2024
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
SparkLabs Primer on Artificial Intelligence 2025
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
How Much Does It Cost to Build a Train Ticket App like Trenitalia in Italy.pptx
Why Endpoint Security Is Critical in a Remote Work Era?
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
agentic-ai-and-the-future-of-autonomous-systems.pdf
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
NewMind AI Weekly Chronicles - August'25 Week I
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
REPORT: Heating appliances market in Poland 2024
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
Transforming Manufacturing operations through Intelligent Integrations
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
Revolutionize Operations with Intelligent IoT Monitoring and Control
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
SparkLabs Primer on Artificial Intelligence 2025
Chapter 2 Digital Image Fundamentals.pdf
NewMind AI Monthly Chronicles - July 2025
How Much Does It Cost to Build a Train Ticket App like Trenitalia in Italy.pptx

Angular 2 overview in 60 minutes