SlideShare a Scribd company logo
Software IndustrySultan Ahmed Sagor
Angular 7
A framework for Presentation Layer
Software IndustrySultan Ahmed Sagor
Software IndustrySultan Ahmed Sagor
7
Software IndustrySultan Ahmed Sagor
Angular Tutorial: Road Covered So Far
Software IndustrySultan Ahmed Sagor
What are Components ?
Now we will discuss components in details
Software IndustrySultan Ahmed Sagor
What are Components ?
A component controls a patch of screen real estate that we can call a view and
declares reusable UI building blocks for an application.
Software IndustrySultan Ahmed Sagor
Components Example
Software IndustrySultan Ahmed Sagor
Components Example
Sidebar
Component
Software IndustrySultan Ahmed Sagor
Components Example
Sidebar
Component
< >
Courses Component
< >
Software IndustrySultan Ahmed Sagor
Components Example
Sidebar
Component
Courses Component
Search Bar < > Nav-Bar < >
Software IndustrySultan Ahmed Sagor
Components Example
Sidebar
Component
Courses Component
Search Bar < > Nav-Bar < >
Header Component < >
Software IndustrySultan Ahmed Sagor
Components Example
Sidebar
Component
Software IndustrySultan Ahmed Sagor
Components Parent/Child Tree Structure
Sidebar
Component
App Component
Sidebar Component Header Component Courses Component
Search Bar Component Nav-bar Component
Software IndustrySultan Ahmed Sagor
What are Components ?
A component controls a patch of screen real estate
that we can call a view and declares reusable UI
building blocks for an application.
Software IndustrySultan Ahmed Sagor
Creating a Component ?
Now we will discuss how to create
components
Software IndustrySultan Ahmed Sagor
Creating a Component
Software IndustrySultan Ahmed Sagor
Creating a Component
A Simple
Type-Script Class
Meta-Data
For Class
Software IndustrySultan Ahmed Sagor
AppComponent: The Root Component ?
Angular is not just a framework.
Software IndustrySultan Ahmed Sagor
Key Points To Remember
Software IndustrySultan Ahmed Sagor
Angular App Bootstrapping
Let us know some basic staffs
Software IndustrySultan Ahmed Sagor
Angular App Bootstrapping
main.ts AppModule AppComponent
❖ Main typescript file from where
the execution begins
❖ Initializes the platform browser
where the app will run and
bootstrap AppModule
❖ Root Module of Angular App
❖ Bootstrap AppComponent and
inserts it into the index.html
host web page
❖ Root Component under which
other components are nested
❖ First Component to inserted in
the DOM.
Software IndustrySultan Ahmed Sagor
main.ts
Software IndustrySultan Ahmed Sagor
AppModule
Software IndustrySultan Ahmed Sagor
AppModule
Software IndustrySultan Ahmed Sagor
AppComponent
Software IndustrySultan Ahmed Sagor
Why Angular Apps Are Bootstrapped
Lets discuss
Software IndustrySultan Ahmed Sagor
Why Angular App is bootstrapped
❖ Allow us to write Angular App that can be hosted on other environments
❖ Import the platform based Applications
❖ For example,
❖ @angular/platform-browser-dynamic is used for running the app on
browser.
Angular is not only a framework for creating WEB-only Applications
Software IndustrySultan Ahmed Sagor
Application Specification
Let us do some practical
Software IndustrySultan Ahmed Sagor
Tour Of Heroes
❖ By the end of this tutorial, we will create the following web page using Angular components.
Software IndustrySultan Ahmed Sagor
Tour Of Heroes
❖ You can click the two links above the dashboard
("Dashboard" and "Heroes") to navigate between this
Dashboard view and a Heroes view.
❖ If you click the dashboard hero "Magneta," the router o
pens a "Hero Details“ view where you can change the hero's name.
Software IndustrySultan Ahmed Sagor
Tour Of Heroes
Clicking the "Back" button returns you to the Dashboard. Links at the top
take you to either of the main views. If you click "Heroes," the app
displays the "Heroes" master list view.
Software IndustrySultan Ahmed Sagor
Tour Of Heroes
❖ When you click a different hero name, the read-
only mini detail beneath the list reflects the new
choice.
❖ You can click the "View Details" button to drill into
the editable details of the selected hero.
Software IndustrySultan Ahmed Sagor
Tour Of Heroes Demo
Let us do develop the application
Software IndustrySultan Ahmed Sagor
Tour Of Heroes
❖ Let us create a Hero component.
❖ Command of creating hero component:
❖ ng generate component heroes
❖ As a result, the following classes/html file will be created:
❖ heroes.component.ts
❖
Software IndustrySultan Ahmed Sagor
heroes.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-heroes',
templateUrl: './heroes.component.html',
styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {
hero: Hero = { id: 1, name: 'Windstorm' };
constructor() { }
ngOnInit() { }
}
Software IndustrySultan Ahmed Sagor
Create a Hero class
❖ Let us create a Hero class to hold all the information that hero can contain
❖ Path: src/app/hero.ts
export class Hero {
id: number;
name: string;
}
Software IndustrySultan Ahmed Sagor
Show the Hero Object
❖ Let us create a Hero class to hold all the information that hero can contain
<h2>{{hero.name}} Details</h2>
<div><span>id: </span>{{hero.id}}</div>
<div><span>name: </span>{{hero.name}}</div>
Software IndustrySultan Ahmed Sagor
Format with UpperCasePipe
❖ Let us create a Hero class to hold all the information that hero can contain
<h2>{{hero.name | uppercase}} Details</h2>
Software IndustrySultan Ahmed Sagor
Edit The hero
❖ Users should be able to edit the hero name in an <input> textbox.
❖ The textbox should both display the hero's name property and update that property as the user types.
❖ That means data flows from the component class out to the screen and from the screen back to the class.
❖ To automate that data flow, setup a two-way data binding between the <input> form element and the
hero.name property.
Software IndustrySultan Ahmed Sagor
Two-Way Binding
<div>
<label>name:
<input [(ngModel)]="hero.name" placeholder="name"/>
</label>
</div>
Software IndustrySultan Ahmed Sagor
The missing FormsModule
❖ Notice that the app stopped working when you added [(ngModel)].
❖ To see the error, open the browser development tools and look in the console for a message like
Software IndustrySultan Ahmed Sagor
AppModule
❖ Angular needs to know how the pieces of your application fit together and what other files and libraries the
app requires. This information is called metadata.
❖ Some of the metadata is in the @Component decorators that you added to your component classes. Other
critical metadata is in @NgModule decorators.
❖ The most important @NgModule decorator annotates the top-level AppModule class.
❖ The Angular CLI generated an AppModule class in src/app/app.module.ts when it created the project. This is
where you opt-in to the FormsModule.
Software IndustrySultan Ahmed Sagor
Import FormsModule
❖ Open AppModule (app.module.ts) and import the FormsModule symbol from the @angular/forms library.
import { FormsModule } from '@angular/forms'; // <-- NgModel lives here
❖ Thenn add FormsModule to the @NgModule metadata's imports array, which contains a list of external modules that the app
needs.
imports: [
BrowserModule,
FormsModule
],
Software IndustrySultan Ahmed Sagor
Declare the HeroesComponent
❖ Every component must be declared in exactly one NgModule.
❖ You didn't declare the HeroesComponent. So why did the application work?
❖ It worked because the Angular CLI declared HeroesComponent in the AppModule when it generated that component
❖ Open src/app/app.module.ts and find HeroesComponent imported near the top.
Software IndustrySultan Ahmed Sagor
Declare the HeroesComponent
import { HeroesComponent } from './heroes/heroes.component';
❖ The HeroesComponent is declared in the @NgModule.declarations array.
declarations: [
AppComponent,
HeroesComponent
],
Software IndustrySultan Ahmed Sagor
Any
question?
Software IndustrySultan Ahmed Sagor
Thank You
Ad

More Related Content

What's hot (20)

Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
WebStackAcademy
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
Knoldus Inc.
 
Building blocks of Angular
Building blocks of AngularBuilding blocks of Angular
Building blocks of Angular
Knoldus Inc.
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
Akshay Mathur
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Edureka!
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
SaleemMalik52
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
Imran Qasim
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
Angular App Presentation
Angular App PresentationAngular App Presentation
Angular App Presentation
Elizabeth Long
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
iFour Technolab Pvt. Ltd.
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipes
Knoldus Inc.
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
Rob Eisenberg
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
Laurent Duveau
 
Angular
AngularAngular
Angular
Mouad EL Fakir
 
Express JS
Express JSExpress JS
Express JS
Alok Guha
 
Angular Lifecycle Hooks
Angular Lifecycle HooksAngular Lifecycle Hooks
Angular Lifecycle Hooks
Squash Apps Pvt Ltd
 
React js
React jsReact js
React js
Oswald Campesato
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
Jadson Santos
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
WebStackAcademy
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
Knoldus Inc.
 
Building blocks of Angular
Building blocks of AngularBuilding blocks of Angular
Building blocks of Angular
Knoldus Inc.
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
Akshay Mathur
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Edureka!
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
SaleemMalik52
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
Imran Qasim
 
Angular App Presentation
Angular App PresentationAngular App Presentation
Angular App Presentation
Elizabeth Long
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipes
Knoldus Inc.
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
Rob Eisenberg
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
Laurent Duveau
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
Jadson Santos
 

Similar to Angular components (20)

UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptxUQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
TamalDey28
 
Angular IO
Angular IOAngular IO
Angular IO
Jennifer Estrada
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
An Overview of Angular 4
An Overview of Angular 4 An Overview of Angular 4
An Overview of Angular 4
Cynoteck Technology Solutions Private Limited
 
Angular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdf
JohnLeo57
 
mean stack
mean stackmean stack
mean stack
michaelaaron25322
 
Angular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advancedAngular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advanced
Preetha Ganapathi
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
Amr Elghadban (AmrAngry)
 
Angular routing
Angular routingAngular routing
Angular routing
Sultan Ahmed
 
Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018
Matt Raible
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
GlobalLogic Ukraine
 
ASP.NEt MVC and Angular What a couple
ASP.NEt MVC and Angular What a coupleASP.NEt MVC and Angular What a couple
ASP.NEt MVC and Angular What a couple
Alexandre Marreiros
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
TejinderMakkar
 
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive FormsAngular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Digamber Singh
 
Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...
Katy Slemon
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
RapidValue
 
Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1
Ahmed Moawad
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
Pratik Patel
 
Start your journey with angular | Basic Angular
Start your journey with angular | Basic AngularStart your journey with angular | Basic Angular
Start your journey with angular | Basic Angular
Anwarul Islam
 
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
Katy Slemon
 
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptxUQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
TamalDey28
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
Angular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdf
JohnLeo57
 
Angular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advancedAngular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advanced
Preetha Ganapathi
 
Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018
Matt Raible
 
ASP.NEt MVC and Angular What a couple
ASP.NEt MVC and Angular What a coupleASP.NEt MVC and Angular What a couple
ASP.NEt MVC and Angular What a couple
Alexandre Marreiros
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
TejinderMakkar
 
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive FormsAngular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Digamber Singh
 
Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...
Katy Slemon
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
RapidValue
 
Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1
Ahmed Moawad
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
Pratik Patel
 
Start your journey with angular | Basic Angular
Start your journey with angular | Basic AngularStart your journey with angular | Basic Angular
Start your journey with angular | Basic Angular
Anwarul Islam
 
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
Katy Slemon
 
Ad

Recently uploaded (20)

UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...
UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...
UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...
Tushar kumar
 
Latest Questions & Answers | Prepare for H3C GB0-961 Certification
Latest Questions & Answers | Prepare for H3C GB0-961 CertificationLatest Questions & Answers | Prepare for H3C GB0-961 Certification
Latest Questions & Answers | Prepare for H3C GB0-961 Certification
NWEXAM
 
GENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautifulGENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautiful
12213013
 
sorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).pptsorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).ppt
IndalSatnami
 
Top Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality EducationTop Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality Education
top10privatecolleges
 
COMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELS
COMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELS
COMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELS
johncena77770789
 
remakingyourselfpresentation-250430095415-6476ade1.pptx
remakingyourselfpresentation-250430095415-6476ade1.pptxremakingyourselfpresentation-250430095415-6476ade1.pptx
remakingyourselfpresentation-250430095415-6476ade1.pptx
lakhmanpindariya9176
 
History of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptxHistory of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptx
Neelesh Raipuria
 
material-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptxmaterial-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptx
JyotirmayNirankari
 
Lecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomicLecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomic
mdrakibhasan1427
 
Placement cell of college - why choose me
Placement cell of college - why choose mePlacement cell of college - why choose me
Placement cell of college - why choose me
mmanvi024
 
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdfLCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
rafaelsago2015
 
Huckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptxHuckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptx
study2022bsc
 
English For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication SkillsEnglish For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication Skills
ankitbeherabiru
 
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
shenleighmaemolina
 
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDHSEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
123candemet2003
 
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and PortugalPixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
TechMeetups
 
CHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptxCHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptx
72200337
 
Science Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaau
Science Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaauScience Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaau
Science Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaau
atifkhan990367
 
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptxSHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
ArshjotSingh30
 
UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...
UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...
UPSC+BAProgramme Syllabus for students who want to pursue UPSC coaching from ...
Tushar kumar
 
Latest Questions & Answers | Prepare for H3C GB0-961 Certification
Latest Questions & Answers | Prepare for H3C GB0-961 CertificationLatest Questions & Answers | Prepare for H3C GB0-961 Certification
Latest Questions & Answers | Prepare for H3C GB0-961 Certification
NWEXAM
 
GENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautifulGENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautiful
12213013
 
sorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).pptsorcesofdrugs-160228074 56 4246643544 (3).ppt
sorcesofdrugs-160228074 56 4246643544 (3).ppt
IndalSatnami
 
Top Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality EducationTop Business Schools in Delhi For Quality Education
Top Business Schools in Delhi For Quality Education
top10privatecolleges
 
COMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELS
COMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELS
COMPRESSION MODELSCOMPRESSION MODELSCOMPRESSION MODELS
johncena77770789
 
remakingyourselfpresentation-250430095415-6476ade1.pptx
remakingyourselfpresentation-250430095415-6476ade1.pptxremakingyourselfpresentation-250430095415-6476ade1.pptx
remakingyourselfpresentation-250430095415-6476ade1.pptx
lakhmanpindariya9176
 
History of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptxHistory of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptx
Neelesh Raipuria
 
material-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptxmaterial-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptx
JyotirmayNirankari
 
Lecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomicLecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomic
mdrakibhasan1427
 
Placement cell of college - why choose me
Placement cell of college - why choose mePlacement cell of college - why choose me
Placement cell of college - why choose me
mmanvi024
 
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdfLCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
LCL216_2024-2_WEEKS 4 & 5_IF CLAUSES (1).pdf
rafaelsago2015
 
Huckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptxHuckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptx
study2022bsc
 
English For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication SkillsEnglish For Carrier, It enhance your Communication Skills
English For Carrier, It enhance your Communication Skills
ankitbeherabiru
 
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
What's the Volume Quiz Presentation in Green Grey Purple Simple Lined Style (...
shenleighmaemolina
 
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDHSEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
123candemet2003
 
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and PortugalPixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
TechMeetups
 
CHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptxCHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptx
72200337
 
Science Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaau
Science Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaauScience Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaau
Science Lab Safety PPT.pptxwgyie ulbyaaaaaaaaaaaaaaaaaaaaaau
atifkhan990367
 
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptxSHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
SHIPPING CONTAINdccdcdERS BC (2).pdf.pptx
ArshjotSingh30
 
Ad

Angular components

  • 1. Software IndustrySultan Ahmed Sagor Angular 7 A framework for Presentation Layer
  • 4. Software IndustrySultan Ahmed Sagor Angular Tutorial: Road Covered So Far
  • 5. Software IndustrySultan Ahmed Sagor What are Components ? Now we will discuss components in details
  • 6. Software IndustrySultan Ahmed Sagor What are Components ? A component controls a patch of screen real estate that we can call a view and declares reusable UI building blocks for an application.
  • 7. Software IndustrySultan Ahmed Sagor Components Example
  • 8. Software IndustrySultan Ahmed Sagor Components Example Sidebar Component
  • 9. Software IndustrySultan Ahmed Sagor Components Example Sidebar Component < > Courses Component < >
  • 10. Software IndustrySultan Ahmed Sagor Components Example Sidebar Component Courses Component Search Bar < > Nav-Bar < >
  • 11. Software IndustrySultan Ahmed Sagor Components Example Sidebar Component Courses Component Search Bar < > Nav-Bar < > Header Component < >
  • 12. Software IndustrySultan Ahmed Sagor Components Example Sidebar Component
  • 13. Software IndustrySultan Ahmed Sagor Components Parent/Child Tree Structure Sidebar Component App Component Sidebar Component Header Component Courses Component Search Bar Component Nav-bar Component
  • 14. Software IndustrySultan Ahmed Sagor What are Components ? A component controls a patch of screen real estate that we can call a view and declares reusable UI building blocks for an application.
  • 15. Software IndustrySultan Ahmed Sagor Creating a Component ? Now we will discuss how to create components
  • 16. Software IndustrySultan Ahmed Sagor Creating a Component
  • 17. Software IndustrySultan Ahmed Sagor Creating a Component A Simple Type-Script Class Meta-Data For Class
  • 18. Software IndustrySultan Ahmed Sagor AppComponent: The Root Component ? Angular is not just a framework.
  • 19. Software IndustrySultan Ahmed Sagor Key Points To Remember
  • 20. Software IndustrySultan Ahmed Sagor Angular App Bootstrapping Let us know some basic staffs
  • 21. Software IndustrySultan Ahmed Sagor Angular App Bootstrapping main.ts AppModule AppComponent ❖ Main typescript file from where the execution begins ❖ Initializes the platform browser where the app will run and bootstrap AppModule ❖ Root Module of Angular App ❖ Bootstrap AppComponent and inserts it into the index.html host web page ❖ Root Component under which other components are nested ❖ First Component to inserted in the DOM.
  • 23. Software IndustrySultan Ahmed Sagor AppModule
  • 24. Software IndustrySultan Ahmed Sagor AppModule
  • 25. Software IndustrySultan Ahmed Sagor AppComponent
  • 26. Software IndustrySultan Ahmed Sagor Why Angular Apps Are Bootstrapped Lets discuss
  • 27. Software IndustrySultan Ahmed Sagor Why Angular App is bootstrapped ❖ Allow us to write Angular App that can be hosted on other environments ❖ Import the platform based Applications ❖ For example, ❖ @angular/platform-browser-dynamic is used for running the app on browser. Angular is not only a framework for creating WEB-only Applications
  • 28. Software IndustrySultan Ahmed Sagor Application Specification Let us do some practical
  • 29. Software IndustrySultan Ahmed Sagor Tour Of Heroes ❖ By the end of this tutorial, we will create the following web page using Angular components.
  • 30. Software IndustrySultan Ahmed Sagor Tour Of Heroes ❖ You can click the two links above the dashboard ("Dashboard" and "Heroes") to navigate between this Dashboard view and a Heroes view. ❖ If you click the dashboard hero "Magneta," the router o pens a "Hero Details“ view where you can change the hero's name.
  • 31. Software IndustrySultan Ahmed Sagor Tour Of Heroes Clicking the "Back" button returns you to the Dashboard. Links at the top take you to either of the main views. If you click "Heroes," the app displays the "Heroes" master list view.
  • 32. Software IndustrySultan Ahmed Sagor Tour Of Heroes ❖ When you click a different hero name, the read- only mini detail beneath the list reflects the new choice. ❖ You can click the "View Details" button to drill into the editable details of the selected hero.
  • 33. Software IndustrySultan Ahmed Sagor Tour Of Heroes Demo Let us do develop the application
  • 34. Software IndustrySultan Ahmed Sagor Tour Of Heroes ❖ Let us create a Hero component. ❖ Command of creating hero component: ❖ ng generate component heroes ❖ As a result, the following classes/html file will be created: ❖ heroes.component.ts ❖
  • 35. Software IndustrySultan Ahmed Sagor heroes.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-heroes', templateUrl: './heroes.component.html', styleUrls: ['./heroes.component.css'] }) export class HeroesComponent implements OnInit { hero: Hero = { id: 1, name: 'Windstorm' }; constructor() { } ngOnInit() { } }
  • 36. Software IndustrySultan Ahmed Sagor Create a Hero class ❖ Let us create a Hero class to hold all the information that hero can contain ❖ Path: src/app/hero.ts export class Hero { id: number; name: string; }
  • 37. Software IndustrySultan Ahmed Sagor Show the Hero Object ❖ Let us create a Hero class to hold all the information that hero can contain <h2>{{hero.name}} Details</h2> <div><span>id: </span>{{hero.id}}</div> <div><span>name: </span>{{hero.name}}</div>
  • 38. Software IndustrySultan Ahmed Sagor Format with UpperCasePipe ❖ Let us create a Hero class to hold all the information that hero can contain <h2>{{hero.name | uppercase}} Details</h2>
  • 39. Software IndustrySultan Ahmed Sagor Edit The hero ❖ Users should be able to edit the hero name in an <input> textbox. ❖ The textbox should both display the hero's name property and update that property as the user types. ❖ That means data flows from the component class out to the screen and from the screen back to the class. ❖ To automate that data flow, setup a two-way data binding between the <input> form element and the hero.name property.
  • 40. Software IndustrySultan Ahmed Sagor Two-Way Binding <div> <label>name: <input [(ngModel)]="hero.name" placeholder="name"/> </label> </div>
  • 41. Software IndustrySultan Ahmed Sagor The missing FormsModule ❖ Notice that the app stopped working when you added [(ngModel)]. ❖ To see the error, open the browser development tools and look in the console for a message like
  • 42. Software IndustrySultan Ahmed Sagor AppModule ❖ Angular needs to know how the pieces of your application fit together and what other files and libraries the app requires. This information is called metadata. ❖ Some of the metadata is in the @Component decorators that you added to your component classes. Other critical metadata is in @NgModule decorators. ❖ The most important @NgModule decorator annotates the top-level AppModule class. ❖ The Angular CLI generated an AppModule class in src/app/app.module.ts when it created the project. This is where you opt-in to the FormsModule.
  • 43. Software IndustrySultan Ahmed Sagor Import FormsModule ❖ Open AppModule (app.module.ts) and import the FormsModule symbol from the @angular/forms library. import { FormsModule } from '@angular/forms'; // <-- NgModel lives here ❖ Thenn add FormsModule to the @NgModule metadata's imports array, which contains a list of external modules that the app needs. imports: [ BrowserModule, FormsModule ],
  • 44. Software IndustrySultan Ahmed Sagor Declare the HeroesComponent ❖ Every component must be declared in exactly one NgModule. ❖ You didn't declare the HeroesComponent. So why did the application work? ❖ It worked because the Angular CLI declared HeroesComponent in the AppModule when it generated that component ❖ Open src/app/app.module.ts and find HeroesComponent imported near the top.
  • 45. Software IndustrySultan Ahmed Sagor Declare the HeroesComponent import { HeroesComponent } from './heroes/heroes.component'; ❖ The HeroesComponent is declared in the @NgModule.declarations array. declarations: [ AppComponent, HeroesComponent ],
  • 46. Software IndustrySultan Ahmed Sagor Any question?
  • 47. Software IndustrySultan Ahmed Sagor Thank You