SlideShare a Scribd company logo
Exploring
Angular 2
Ahmed Moawad
Course Prerequisites
<HTML
CSS} JavaScript
Course Objectives
Learn about Angular 2 and
it amazing features
Learn how to treat the web app as set
of blocks that integrate with each other
What is Angular 2 ?
AngularJS is a structural framework for dynamic web apps
extend HTML's syntax to express your
application's components.
eliminate much of the code you
would otherwise have to write.
It just a new language
TypeScript
Variable Declaration TypeScript
identifier : type = value
var name: string = “Ahmed”
let age: number = 17
let isStudent: boolean = True
var salary: any = “1900”
let
var
Data Types TypeScript
string
number
boolean
Array
any
void
null
undefined
Functions TypeScript
function add(x: number, y: number): number{
return x + y;
}
Classes TypeScript
class Animal {
private name: string;
constructor(aname: string) {
this.name = aname;
}
move(distanceInMeters: number = 0)
{}
static doStatic()
{}
}
class Horse extends Animal {
constructor(name: string) { super(name);}
}
Modules TypeScript
export function sum (x, y) {
return x + y
}
export var dept = “OS”
import * as i from “index”;
console.log(i.dept);
//OR
import {sum} from “index”;
sum(1,2);
index.ts home.ts
Let’s go back to
Angular 2
Architecture
Big Picture Architecture
Component
{}
Template
</>
Injector
Directives
Metadata
Metadata
Property Binding
Event Binding
Service
Structural Directive
Component Directive
Attribute Directive
The basic unit of Angular 2
Components
Intro Components
A component controls a patch of screen called a view.
Angular 2 App is constructed of components that integrate with each other.
Component
{}
Metadata
Decorator Components
@Component({
//Metadata Properties
})
export class AppComponent{
//The Component Class
}
Component decorator allows you to mark a class as an Angular component and provide
additional metadata that determines how the component should be processed, instantiated
and used at runtime.
Metadata Properties Components
@Component({
selector: “app-comp”
})
export class AppComponent{}
Metadata Properties are the data that Angular 2 use to prepare the Component
selector
template
templateUrl
styles
Declare the name that we select the component by in html.
Declare the component inline-defined html template.
-Declare the url of html file that contain the template.
Declare the component inline-defined style.
styleUrls -Declare the list of urls of style files that applied on the view.
Class Components
@Component({
selector: “app-comp”
template: `<p>Hello World</p>`
})
export class AppComponent{
name: string = “Ahmed”;
}
Class is the blue print of the Component that Angular 2 will insatiate the Component from.
Naming Conventions Components
@Component({
selector: “app-comp”
template: `<p>Hello World</p>`
})
export class AppComponent{
name: string = “Ahmed”;
}
File: <Component Name>.component.ts
Class: <Component Name>Component
app.component.ts
Hello World Component * Components
import { Component } from '@angular/core';
@Component({
selector: “app-comp”
template: `<p>Hello {{name}}!</p>`
})
export class AppComponent{ name: string = “Ahmed”; }
<html>
<body>
<app-comp></app-comp>
</body>
</html>
Hello Ahmed
app.component.ts
index.html Output
*For creating new Angular App, follow the installation instructions at the last section of the slides
The View of the Component
Templates
Intro Templates
A template is a form of HTML that tells Angular how to render the component.
Template
</>
Naming Conventions Templates
<p>Age: {{ age }}</p>
File: <Component Name>.component.html
app.component.html
Expressions Templates
{{ expression }}
A template expression produces a value.
Angular executes the expression and assigns it to a property of a binding target
Template Expressions look like JavaScript Expressions except that we cant use the following:
1. assignment operators (=, += , -=).
2. new operator.
3. ; or , .
4. increment (++) or decrement operators (- -) .
Example Templates
@Component({
selector: “app-comp”
templateUrl: “./app.html”
})
export class AppComponent{
age: number = 13;
}
<html>
<body>
<app-comp></app-comp>
</body>
</html>
Age: 28
app.component.ts
index.html Output
<p>Age: {{age+15}}</p>
app.component.html
Templates
Data Binding
Types Data Binding
Binding
[({})]
One-way Binding Two-way Binding
From Component
to View
From View to
Component
ngModel
Interpolation Property
ClassStyle Attribute
Events
Interpolation Data Binding
{{ expression }}
Example
@Component({ .... })
export class AppComponent{
name: string = “Open Source”;
....
}
<p> Hello, {{name}} </p>
app.component.html
Hello, Open Source
app.component.ts
Property Binding Data Binding
[property] = "expression"
Example
@Component({ .... })
export class AppComponent{
imageUrl: string = “kiwi-juice.png”;
....
}
app.component.ts
<img [src]=“imageUrl” />
app.component.html
Attribute Binding Data Binding
[attr.<attr-name>] = "expression"
Example
@Component({ .... })
export class AppComponent{
imageUrl: string = “kiwi-juice.png”;
....
}
app.component.ts
<img [attr.src]=“imageUrl” />
app.component.html
Style Binding Data Binding
[style.<style-name>] = "expression"
Example
@Component({ .... })
export class AppComponent{
bg: string= “#ff0000”;
....
}
app.component.ts
<div [style.background]=“bg”></div>
app.component.html
Class Binding Data Binding
[class.<class-name>] = "expression"
Example
@Component({ .... })
export class AppComponent{
isHidden: boolean= true;
....
}
app.component.ts
<div [class.hide]=“isHidden”></div>
app.component.html
Event Binding Data Binding
(event) = “statement"
Example
@Component({ .... })
export class AppComponent{
save(){
console.log(“Saved”);
}
}
<button (click)=“save()”>Save</button>
app.component.html
Save
Saved
console
app.component.ts
Prestige
$event Event Binding
Example
export class AppComponent{
movie=“Prestige”;
changeIt(m){
this.movie= m;
}
}
<input (input)=“changeIt($event.target.value)”>
<p>{{movie}}</p>
app.component.html
app.component.ts
$event is the Event Object that contains all the data of the Event Occurs to the target
Up
Up
ngModel
[(ngModel)] = “expression”
Two-way Binding
Prestige
Example
export class AppComponent{
movie=“Prestige”;
}
<input [(ngModel)]=“movie”>
<p>{{movie}}</p>
app.component.html
app.component.ts
Up
Up
It helps you when you need it
Modules
Intro Modules
Modules help organize an application into cohesive blocks of functionality.
Modules
App Module Modules
imports
-Import the modules that you need in your App.
Example: BrowserModule
declarations
Declare the components and directives that belong to your angular
App.
bootstrap -Declare the bootstrap component that your application.
Every Angular app has a root module class. By convention, the root module class is called
AppModule and it exists in a file named app.module.ts.
@NgModule({
imports: [],
declarations: [],
bootstrap: []
})
export class AppModule{}
Let’s Collect ’em all
Bootstrap Your App
Main Bootstrap Your App
import { platformBrowserDynamic } from '@angular/platform-
browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
main.ts
Lab Assignments
If you have Syntax Error, Solve it yourself. You are able to do that.1
Mentors exist to guide you to the best way to solve the problem not to solve the
problem or your syntax errors.
2
Steps of Solving the problem:
- Think.
- Think again.
- Use Pen and Papers to convert your thoughts into Procedures.
- Convert your previous pseudo code into JavaScript Code using
its syntax rules.
- Don’t be afraid of syntax errors. It is easy to solve. Read it clearly
and you will solve it.
- Check the output of every step you do and then check them all.
3
The most important rule is to enjoy challenging yourself and don’t stress your mind by the
headache of assignments delivery’s deadlines.
4
Rules
Angular Installation
Windows Node & NPM Installation
Website: https://www.nodejs.org
Download the convenient Node version from the official website:1
Run the executable file downloaded and follow the instructions2
Check Node and npm version:3
$ node –v
$ npm -v
Linux Node & NPM Installation
Run the following commands
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs
$ node –v
$ npm –v
Angular CLI Angular Installation
Install Angular CLI
$ npm install -g @angular/cli
$ ng new os-app
$ cd os-app
$ ng serve
Now App serve at localhost:4200
LAB Beginner
Movies DB App : Static Movie Example
Moon Light
Director: Barry Jenkins
Writer: Tarell Alvin McCraney
Actors:
Mahershala Ali,
Shariff Earp,
Duan Sanderson
7.8
LAB Intermediate
Movies DB App : Edit person Example
Moon Light
Director: Barry Jenkins
Writer: Tarell Alvin McCraney
Actors:
Mahershala Ali,
Shariff Earp,
Duan Sanderson
7.8
Name
Nationality
Rating
4.5
4.5
I’m Ahmed. I’m from Egypt
LAB Advanced
Movies DB App : Change Movie Example
Name
Nationality
Rating 4.5
I’m Ahmed. I’m from Egypt
4.5
Manchester by Sea
Director: Kenneth Lonergan
Writer: Kenneth Lonergan
Stars:
Casey Affleck,
Michelle Williams,
Kyle Chandler
8
Flash
For the first one that who has completed the
required assignments
Captain America
For the one who has the minimum syntax
errors and his code is well organized
Iron Man
For the one who has the most generic
and strong code
Thor
For the one who find the best and
shortest way to solve the problems
LAB Badges
Thank You
ahmedmowd@gmail.com
To be continued … in the next level

More Related Content

PDF
Exploring Angular 2 - Episode 2
PDF
Angular 2 Essential Training
PDF
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
PDF
Tech Webinar: Angular 2, Introduction to a new framework
PDF
Commit University - Exploring Angular 2
PDF
Angular 2 - The Next Framework
ODP
Introduction to Angular 2
PPTX
An afternoon with angular 2
Exploring Angular 2 - Episode 2
Angular 2 Essential Training
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Tech Webinar: Angular 2, Introduction to a new framework
Commit University - Exploring Angular 2
Angular 2 - The Next Framework
Introduction to Angular 2
An afternoon with angular 2

What's hot (20)

PPTX
PPTX
Angular js 2
PDF
Angular2 Development for Java developers
PDF
Quick introduction to Angular 4 for AngularJS 1.5 developers
PDF
Seven Versions of One Web Application
PDF
Introduction to Angular 2
PPTX
Angular2 for Beginners
PPTX
Angular1x and Angular 2 for Beginners
PDF
Dart for Java Developers
PDF
Overview of the AngularJS framework
PPTX
Single Page Applications with AngularJS 2.0
PDF
Intro to JavaScript
PPTX
PDF
Data Flow Patterns in Angular 2 - Sebastian Müller
PDF
Angular 4 for Java Developers
PDF
Angular 2: core concepts
PDF
Speed up your Web applications with HTML5 WebSockets
PDF
Angular 2: What's New?
PPTX
Async patterns in javascript
PDF
Angular Application Testing
Angular js 2
Angular2 Development for Java developers
Quick introduction to Angular 4 for AngularJS 1.5 developers
Seven Versions of One Web Application
Introduction to Angular 2
Angular2 for Beginners
Angular1x and Angular 2 for Beginners
Dart for Java Developers
Overview of the AngularJS framework
Single Page Applications with AngularJS 2.0
Intro to JavaScript
Data Flow Patterns in Angular 2 - Sebastian Müller
Angular 4 for Java Developers
Angular 2: core concepts
Speed up your Web applications with HTML5 WebSockets
Angular 2: What's New?
Async patterns in javascript
Angular Application Testing
Ad

Similar to Exploring Angular 2 - Episode 1 (20)

PPTX
Angular 2 KTS
PPTX
Angular Framework ppt for beginners and advanced
PPTX
PDF
Angular Notes.pdf
PPTX
Angularjs2 presentation
PDF
better-apps-angular-2-day1.pdf and home
PPTX
yrs of IT experience in enterprise programming
PPTX
Fly High With Angular - How to build an app using Angular
PPTX
Angular Course.pptx
PPTX
An evening with Angular 2
PDF
Angular2 with type script
PPTX
Foster - Getting started with Angular
PDF
Angular 2 overview in 60 minutes
PDF
Angular JS2 Training Session #1
PPTX
Angularj2.0
PPTX
Angular4 getting started
PPTX
Angular 2 On Production (IT Talk in Dnipro)
PPTX
Angular IO
PDF
Angular2 with TypeScript
PPTX
Unit 2 - Data Binding.pptx
Angular 2 KTS
Angular Framework ppt for beginners and advanced
Angular Notes.pdf
Angularjs2 presentation
better-apps-angular-2-day1.pdf and home
yrs of IT experience in enterprise programming
Fly High With Angular - How to build an app using Angular
Angular Course.pptx
An evening with Angular 2
Angular2 with type script
Foster - Getting started with Angular
Angular 2 overview in 60 minutes
Angular JS2 Training Session #1
Angularj2.0
Angular4 getting started
Angular 2 On Production (IT Talk in Dnipro)
Angular IO
Angular2 with TypeScript
Unit 2 - Data Binding.pptx
Ad

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Transform Your Business with a Software ERP System
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Introduction to Artificial Intelligence
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
top salesforce developer skills in 2025.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
System and Network Administraation Chapter 3
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Transform Your Business with a Software ERP System
Adobe Illustrator 28.6 Crack My Vision of Vector Design
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Nekopoi APK 2025 free lastest update
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Designing Intelligence for the Shop Floor.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Digital Systems & Binary Numbers (comprehensive )
Introduction to Artificial Intelligence
Navsoft: AI-Powered Business Solutions & Custom Software Development
Wondershare Filmora 15 Crack With Activation Key [2025
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
top salesforce developer skills in 2025.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
L1 - Introduction to python Backend.pptx
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
System and Network Administraation Chapter 3

Exploring Angular 2 - Episode 1

  • 3. Course Objectives Learn about Angular 2 and it amazing features Learn how to treat the web app as set of blocks that integrate with each other
  • 4. What is Angular 2 ? AngularJS is a structural framework for dynamic web apps extend HTML's syntax to express your application's components. eliminate much of the code you would otherwise have to write.
  • 5. It just a new language TypeScript
  • 6. Variable Declaration TypeScript identifier : type = value var name: string = “Ahmed” let age: number = 17 let isStudent: boolean = True var salary: any = “1900” let var
  • 8. Functions TypeScript function add(x: number, y: number): number{ return x + y; }
  • 9. Classes TypeScript class Animal { private name: string; constructor(aname: string) { this.name = aname; } move(distanceInMeters: number = 0) {} static doStatic() {} } class Horse extends Animal { constructor(name: string) { super(name);} }
  • 10. Modules TypeScript export function sum (x, y) { return x + y } export var dept = “OS” import * as i from “index”; console.log(i.dept); //OR import {sum} from “index”; sum(1,2); index.ts home.ts
  • 11. Let’s go back to Angular 2
  • 13. Big Picture Architecture Component {} Template </> Injector Directives Metadata Metadata Property Binding Event Binding Service Structural Directive Component Directive Attribute Directive
  • 14. The basic unit of Angular 2 Components
  • 15. Intro Components A component controls a patch of screen called a view. Angular 2 App is constructed of components that integrate with each other. Component {} Metadata
  • 16. Decorator Components @Component({ //Metadata Properties }) export class AppComponent{ //The Component Class } Component decorator allows you to mark a class as an Angular component and provide additional metadata that determines how the component should be processed, instantiated and used at runtime.
  • 17. Metadata Properties Components @Component({ selector: “app-comp” }) export class AppComponent{} Metadata Properties are the data that Angular 2 use to prepare the Component selector template templateUrl styles Declare the name that we select the component by in html. Declare the component inline-defined html template. -Declare the url of html file that contain the template. Declare the component inline-defined style. styleUrls -Declare the list of urls of style files that applied on the view.
  • 18. Class Components @Component({ selector: “app-comp” template: `<p>Hello World</p>` }) export class AppComponent{ name: string = “Ahmed”; } Class is the blue print of the Component that Angular 2 will insatiate the Component from.
  • 19. Naming Conventions Components @Component({ selector: “app-comp” template: `<p>Hello World</p>` }) export class AppComponent{ name: string = “Ahmed”; } File: <Component Name>.component.ts Class: <Component Name>Component app.component.ts
  • 20. Hello World Component * Components import { Component } from '@angular/core'; @Component({ selector: “app-comp” template: `<p>Hello {{name}}!</p>` }) export class AppComponent{ name: string = “Ahmed”; } <html> <body> <app-comp></app-comp> </body> </html> Hello Ahmed app.component.ts index.html Output *For creating new Angular App, follow the installation instructions at the last section of the slides
  • 21. The View of the Component Templates
  • 22. Intro Templates A template is a form of HTML that tells Angular how to render the component. Template </>
  • 23. Naming Conventions Templates <p>Age: {{ age }}</p> File: <Component Name>.component.html app.component.html
  • 24. Expressions Templates {{ expression }} A template expression produces a value. Angular executes the expression and assigns it to a property of a binding target Template Expressions look like JavaScript Expressions except that we cant use the following: 1. assignment operators (=, += , -=). 2. new operator. 3. ; or , . 4. increment (++) or decrement operators (- -) .
  • 25. Example Templates @Component({ selector: “app-comp” templateUrl: “./app.html” }) export class AppComponent{ age: number = 13; } <html> <body> <app-comp></app-comp> </body> </html> Age: 28 app.component.ts index.html Output <p>Age: {{age+15}}</p> app.component.html
  • 27. Types Data Binding Binding [({})] One-way Binding Two-way Binding From Component to View From View to Component ngModel Interpolation Property ClassStyle Attribute Events
  • 28. Interpolation Data Binding {{ expression }} Example @Component({ .... }) export class AppComponent{ name: string = “Open Source”; .... } <p> Hello, {{name}} </p> app.component.html Hello, Open Source app.component.ts
  • 29. Property Binding Data Binding [property] = "expression" Example @Component({ .... }) export class AppComponent{ imageUrl: string = “kiwi-juice.png”; .... } app.component.ts <img [src]=“imageUrl” /> app.component.html
  • 30. Attribute Binding Data Binding [attr.<attr-name>] = "expression" Example @Component({ .... }) export class AppComponent{ imageUrl: string = “kiwi-juice.png”; .... } app.component.ts <img [attr.src]=“imageUrl” /> app.component.html
  • 31. Style Binding Data Binding [style.<style-name>] = "expression" Example @Component({ .... }) export class AppComponent{ bg: string= “#ff0000”; .... } app.component.ts <div [style.background]=“bg”></div> app.component.html
  • 32. Class Binding Data Binding [class.<class-name>] = "expression" Example @Component({ .... }) export class AppComponent{ isHidden: boolean= true; .... } app.component.ts <div [class.hide]=“isHidden”></div> app.component.html
  • 33. Event Binding Data Binding (event) = “statement" Example @Component({ .... }) export class AppComponent{ save(){ console.log(“Saved”); } } <button (click)=“save()”>Save</button> app.component.html Save Saved console app.component.ts
  • 34. Prestige $event Event Binding Example export class AppComponent{ movie=“Prestige”; changeIt(m){ this.movie= m; } } <input (input)=“changeIt($event.target.value)”> <p>{{movie}}</p> app.component.html app.component.ts $event is the Event Object that contains all the data of the Event Occurs to the target Up Up
  • 35. ngModel [(ngModel)] = “expression” Two-way Binding Prestige Example export class AppComponent{ movie=“Prestige”; } <input [(ngModel)]=“movie”> <p>{{movie}}</p> app.component.html app.component.ts Up Up
  • 36. It helps you when you need it Modules
  • 37. Intro Modules Modules help organize an application into cohesive blocks of functionality. Modules
  • 38. App Module Modules imports -Import the modules that you need in your App. Example: BrowserModule declarations Declare the components and directives that belong to your angular App. bootstrap -Declare the bootstrap component that your application. Every Angular app has a root module class. By convention, the root module class is called AppModule and it exists in a file named app.module.ts. @NgModule({ imports: [], declarations: [], bootstrap: [] }) export class AppModule{}
  • 39. Let’s Collect ’em all Bootstrap Your App
  • 40. Main Bootstrap Your App import { platformBrowserDynamic } from '@angular/platform- browser-dynamic'; import { AppModule } from './app.module'; platformBrowserDynamic().bootstrapModule(AppModule); main.ts
  • 42. If you have Syntax Error, Solve it yourself. You are able to do that.1 Mentors exist to guide you to the best way to solve the problem not to solve the problem or your syntax errors. 2 Steps of Solving the problem: - Think. - Think again. - Use Pen and Papers to convert your thoughts into Procedures. - Convert your previous pseudo code into JavaScript Code using its syntax rules. - Don’t be afraid of syntax errors. It is easy to solve. Read it clearly and you will solve it. - Check the output of every step you do and then check them all. 3 The most important rule is to enjoy challenging yourself and don’t stress your mind by the headache of assignments delivery’s deadlines. 4 Rules
  • 44. Windows Node & NPM Installation Website: https://www.nodejs.org Download the convenient Node version from the official website:1 Run the executable file downloaded and follow the instructions2 Check Node and npm version:3 $ node –v $ npm -v
  • 45. Linux Node & NPM Installation Run the following commands $ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - $ sudo apt-get install -y nodejs $ node –v $ npm –v
  • 46. Angular CLI Angular Installation Install Angular CLI $ npm install -g @angular/cli $ ng new os-app $ cd os-app $ ng serve Now App serve at localhost:4200
  • 47. LAB Beginner Movies DB App : Static Movie Example Moon Light Director: Barry Jenkins Writer: Tarell Alvin McCraney Actors: Mahershala Ali, Shariff Earp, Duan Sanderson 7.8
  • 48. LAB Intermediate Movies DB App : Edit person Example Moon Light Director: Barry Jenkins Writer: Tarell Alvin McCraney Actors: Mahershala Ali, Shariff Earp, Duan Sanderson 7.8 Name Nationality Rating 4.5 4.5 I’m Ahmed. I’m from Egypt
  • 49. LAB Advanced Movies DB App : Change Movie Example Name Nationality Rating 4.5 I’m Ahmed. I’m from Egypt 4.5 Manchester by Sea Director: Kenneth Lonergan Writer: Kenneth Lonergan Stars: Casey Affleck, Michelle Williams, Kyle Chandler 8
  • 50. Flash For the first one that who has completed the required assignments Captain America For the one who has the minimum syntax errors and his code is well organized Iron Man For the one who has the most generic and strong code Thor For the one who find the best and shortest way to solve the problems LAB Badges
  • 51. Thank You [email protected] To be continued … in the next level