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

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

More Related Content

What's hot

Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
AshokKumar616995
 
Angular Lifecycle Hooks
Angular Lifecycle HooksAngular Lifecycle Hooks
Angular Lifecycle Hooks
Squash Apps Pvt Ltd
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Jennifer Estrada
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
iFour Technolab Pvt. Ltd.
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
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 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
Eyal Vardi
 
React hooks
React hooksReact hooks
React hooks
Assaf Gannon
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Angular
AngularAngular
Angular
Lilia Sfaxi
 
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 tutorial
Angular tutorialAngular tutorial
Angular tutorial
Rohit Gupta
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
Knoldus Inc.
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
Christoffer Noring
 
Angular
AngularAngular
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Malla Reddy University
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
SaleemMalik52
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
WebStackAcademy
 
Angular
AngularAngular
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
Akshay Mathur
 

What's hot (20)

Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
 
Angular Lifecycle Hooks
Angular Lifecycle HooksAngular Lifecycle Hooks
Angular Lifecycle Hooks
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
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...
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
React hooks
React hooksReact hooks
React hooks
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
Angular
AngularAngular
Angular
 
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
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Angular
AngularAngular
Angular
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 
Angular
AngularAngular
Angular
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 

Similar to Angular components

Angular data binding
Angular data binding Angular data binding
Angular data binding
Sultan Ahmed
 
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
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
 

Similar to Angular components (20)

Angular data binding
Angular data binding Angular data binding
Angular data binding
 
Angular IO
Angular IOAngular IO
Angular IO
 
Angular 8
Angular 8 Angular 8
Angular 8
 
An Overview of Angular 4
An Overview of Angular 4 An Overview of Angular 4
An Overview of Angular 4
 
Angular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdf
 
mean stack
mean stackmean stack
mean stack
 
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
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
 
Angular routing
Angular routingAngular routing
Angular routing
 
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
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
 
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
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
 
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
 
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...
 
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
 
Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1Exploring Angular 2 - Episode 1
Exploring Angular 2 - Episode 1
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
 
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
 
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...
 

Recently uploaded

Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model SafeConnaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
tinakumariji156
 
Mumbai Central @Call @Girls Whatsapp 9920725232 With High Profile Offer
Mumbai Central @Call @Girls Whatsapp 9920725232 With High Profile OfferMumbai Central @Call @Girls Whatsapp 9920725232 With High Profile Offer
Mumbai Central @Call @Girls Whatsapp 9920725232 With High Profile Offer
kanikaroy14
 
Draft of mate seeking before marriage...
Draft of mate seeking before marriage...Draft of mate seeking before marriage...
Draft of mate seeking before marriage...
islamiato717
 
Noida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model Safe
Noida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model SafeNoida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model Safe
Noida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model Safe
anchal singh$A17
 
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model SafeConnaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
aashuverma204
 
Manavi vishwas girigosavi resume for career.pdf
Manavi vishwas girigosavi resume for career.pdfManavi vishwas girigosavi resume for career.pdf
Manavi vishwas girigosavi resume for career.pdf
sanikaphadatare48
 
Basic Of Civil Engineering Site knowledge
Basic Of Civil Engineering Site knowledgeBasic Of Civil Engineering Site knowledge
Basic Of Civil Engineering Site knowledge
SuvamoyPanja
 
( Call  ) Girls Ghaziabad 9873940964 High Profile
( Call  ) Girls Ghaziabad 9873940964 High Profile( Call  ) Girls Ghaziabad 9873940964 High Profile
( Call  ) Girls Ghaziabad 9873940964 High Profile
butwhat24
 
Mitali Sawant BCA student of MKSSS resume.pdf
Mitali Sawant BCA student of MKSSS resume.pdfMitali Sawant BCA student of MKSSS resume.pdf
Mitali Sawant BCA student of MKSSS resume.pdf
sawantmitali1430
 
MBA SC ODL IV Sem Scheme Syllabus us.pdf
MBA SC ODL IV Sem Scheme Syllabus us.pdfMBA SC ODL IV Sem Scheme Syllabus us.pdf
MBA SC ODL IV Sem Scheme Syllabus us.pdf
knovatechservices
 
Aishwarya Uday Mane Rersume career .pdf
Aishwarya Uday Mane Rersume  career .pdfAishwarya Uday Mane Rersume  career .pdf
Aishwarya Uday Mane Rersume career .pdf
sanikaphadatare48
 
一比一原版(windsor毕业证)温莎大学毕业证如何办理
一比一原版(windsor毕业证)温莎大学毕业证如何办理一比一原版(windsor毕业证)温莎大学毕业证如何办理
一比一原版(windsor毕业证)温莎大学毕业证如何办理
uyudun
 
exploring personal brand for project and portfolio 1
exploring personal brand for project and portfolio 1exploring personal brand for project and portfolio 1
exploring personal brand for project and portfolio 1
gcgonzalez2
 
Pancreatic-Cancer-Sophie-Heriot versatile.pdf
Pancreatic-Cancer-Sophie-Heriot versatile.pdfPancreatic-Cancer-Sophie-Heriot versatile.pdf
Pancreatic-Cancer-Sophie-Heriot versatile.pdf
ShaliniN51
 
medical examiner list dg shipping of India 01072024.pdf
medical examiner list dg shipping of India 01072024.pdfmedical examiner list dg shipping of India 01072024.pdf
medical examiner list dg shipping of India 01072024.pdf
Ajaz321
 
blue professional modern CV resume_20240324_122005_0000.pdf
blue professional modern CV resume_20240324_122005_0000.pdfblue professional modern CV resume_20240324_122005_0000.pdf
blue professional modern CV resume_20240324_122005_0000.pdf
aishwarymane6025
 
reStartEvents Nationwide TS/SCI & Above Cleared Virtual Career Fair
reStartEvents Nationwide TS/SCI & Above Cleared Virtual Career FairreStartEvents Nationwide TS/SCI & Above Cleared Virtual Career Fair
reStartEvents Nationwide TS/SCI & Above Cleared Virtual Career Fair
Ken Fuller
 
Vaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Vaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model SafeVaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Vaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
bookmybebe1
 
ISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdf
ISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdfISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdf
ISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdf
MohammadAdnan6667
 
Career Paths as Civil Graduate in the Era of Digital Transformation
Career Paths as Civil Graduate in the Era of Digital TransformationCareer Paths as Civil Graduate in the Era of Digital Transformation
Career Paths as Civil Graduate in the Era of Digital Transformation
Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 

Recently uploaded (20)

Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model SafeConnaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
 
Mumbai Central @Call @Girls Whatsapp 9920725232 With High Profile Offer
Mumbai Central @Call @Girls Whatsapp 9920725232 With High Profile OfferMumbai Central @Call @Girls Whatsapp 9920725232 With High Profile Offer
Mumbai Central @Call @Girls Whatsapp 9920725232 With High Profile Offer
 
Draft of mate seeking before marriage...
Draft of mate seeking before marriage...Draft of mate seeking before marriage...
Draft of mate seeking before marriage...
 
Noida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model Safe
Noida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model SafeNoida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model Safe
Noida @ℂall @Girls ꧁❤ 9873777170 ❤꧂Glamorous sonam Mehra Top Model Safe
 
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model SafeConnaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Connaught Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
 
Manavi vishwas girigosavi resume for career.pdf
Manavi vishwas girigosavi resume for career.pdfManavi vishwas girigosavi resume for career.pdf
Manavi vishwas girigosavi resume for career.pdf
 
Basic Of Civil Engineering Site knowledge
Basic Of Civil Engineering Site knowledgeBasic Of Civil Engineering Site knowledge
Basic Of Civil Engineering Site knowledge
 
( Call  ) Girls Ghaziabad 9873940964 High Profile
( Call  ) Girls Ghaziabad 9873940964 High Profile( Call  ) Girls Ghaziabad 9873940964 High Profile
( Call  ) Girls Ghaziabad 9873940964 High Profile
 
Mitali Sawant BCA student of MKSSS resume.pdf
Mitali Sawant BCA student of MKSSS resume.pdfMitali Sawant BCA student of MKSSS resume.pdf
Mitali Sawant BCA student of MKSSS resume.pdf
 
MBA SC ODL IV Sem Scheme Syllabus us.pdf
MBA SC ODL IV Sem Scheme Syllabus us.pdfMBA SC ODL IV Sem Scheme Syllabus us.pdf
MBA SC ODL IV Sem Scheme Syllabus us.pdf
 
Aishwarya Uday Mane Rersume career .pdf
Aishwarya Uday Mane Rersume  career .pdfAishwarya Uday Mane Rersume  career .pdf
Aishwarya Uday Mane Rersume career .pdf
 
一比一原版(windsor毕业证)温莎大学毕业证如何办理
一比一原版(windsor毕业证)温莎大学毕业证如何办理一比一原版(windsor毕业证)温莎大学毕业证如何办理
一比一原版(windsor毕业证)温莎大学毕业证如何办理
 
exploring personal brand for project and portfolio 1
exploring personal brand for project and portfolio 1exploring personal brand for project and portfolio 1
exploring personal brand for project and portfolio 1
 
Pancreatic-Cancer-Sophie-Heriot versatile.pdf
Pancreatic-Cancer-Sophie-Heriot versatile.pdfPancreatic-Cancer-Sophie-Heriot versatile.pdf
Pancreatic-Cancer-Sophie-Heriot versatile.pdf
 
medical examiner list dg shipping of India 01072024.pdf
medical examiner list dg shipping of India 01072024.pdfmedical examiner list dg shipping of India 01072024.pdf
medical examiner list dg shipping of India 01072024.pdf
 
blue professional modern CV resume_20240324_122005_0000.pdf
blue professional modern CV resume_20240324_122005_0000.pdfblue professional modern CV resume_20240324_122005_0000.pdf
blue professional modern CV resume_20240324_122005_0000.pdf
 
reStartEvents Nationwide TS/SCI & Above Cleared Virtual Career Fair
reStartEvents Nationwide TS/SCI & Above Cleared Virtual Career FairreStartEvents Nationwide TS/SCI & Above Cleared Virtual Career Fair
reStartEvents Nationwide TS/SCI & Above Cleared Virtual Career Fair
 
Vaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Vaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model SafeVaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Vaishali @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
 
ISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdf
ISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdfISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdf
ISB_GRADE_XI_AND_XII_ORIENTATION_PPT AY 2024-2025.pdf
 
Career Paths as Civil Graduate in the Era of Digital Transformation
Career Paths as Civil Graduate in the Era of Digital TransformationCareer Paths as Civil Graduate in the Era of Digital Transformation
Career Paths as Civil Graduate in the Era of Digital Transformation
 

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