SlideShare a Scribd company logo
1 of 29
For Angular Online Training : +91-999 123 502
Introductionto
Angular
Imdad Manik 1
•Angular is written in TypeScript. It
implements core and optional functionality
as a set of TypeScript libraries that you
import into your applications. The
architecture of an Angular application relies
on certain fundamental concepts. The basic
building blocks of the Angular framework
are Angular components.
Introduction to Angular
Imdad Manik 2
Angular Environment Setup
 Install Node.js which includes Node Package Manager
(npm). https://nodejs.org/en/download/
 Visual Studio Code.
https://code.visualstudio.com/download
 Install the Angular CLI globally.
npm install -g @angular/cli
 Create Project.
ng new hello-world
cd hello-world
 Install project dependencies.
npm install
 Run the Application.
ng serve / npm start
Imdad Manik 3
Angular CLI Options
Options Usage
Help ng --help
Build ng build --env
Build and Run ng serve
Testing ng test
End-End Testing ng e2e
Imdad Manik 4
Angular CLI Commands
Scaffold Usage In Short
Module ng generate module my-module ng g m my-module
Component ng generate component my-component ng g c my-component
Directive ng generate directive my-directive ng g d my-directive
Pipe ng generate pipe my-pipe ng g p my-pipe
Service ng generate service my-service ng g s my-service
Guard ng generate guard my-guard ng g g my-guard
Class ng generate class my-class ng g cl my-class
Interface ng generate interface my-interface ng g i my-interface
Enum ng generate enum my-enum ng g e my-enum
Imdad Manik 5
Angular Initialization Process
Imdad Manik 6
Angular Building Blocks
• Modules
• Components
• Templates
• Metadata
• Data binding
• Directives
• Pipes
• Routing
• Forms
• Services
• Dependency injection
Imdad Manik 7
• A module organize an application into unified blocks of
functionality
• An Angular module is a class with an @NgModule
decorator
• Accepts a single metadata object whose properties
describe the module
• Each Angular app must have at least one module, known
as root module
Modules
Imdad Manik 8
Modules
Imdad Manik 9
• imports – Specify other dependent modules whose classes are
required by the component templates declared in the module
• declarations – Specify the components, directives, and pipes that
belong to the module
• bootstrap – Specify the main app view i.e root component. Only
the root module can have this bootstrap property
• exports – A subset of declarations that will be visible and usable
in the other modules. A root module doesn’t have export option.
• providers – Specify the services, accessible across the app
NgModule Metadata Main Properties
Imdad Manik 10
• Angular has built-In library modules starting with the @angular
as prefix
• Built-In library & third part modules can be installed using npm
manager
• Built-In modules, components, services, directives etc. can be
imported by using built-In library modules
Built-In Modules
Imdad Manik 11
• A type of directives with template, styles and logic for
user interaction
• Exported as a custom HTML tag like as:
 <my-component></my-component>
ng g c my-component
Component
Imdad Manik 12
Angular Components Page View
ROOT COMPONENT
HEADER COMPONENT
FOOTER COMPONENT
ARTICLE
COMPONENT
COMMENTS
COMPONENT
CATEGORIES
COMPONENT
NEWS FEEDS
COMPONENT
Imdad Manik 13
Component Example
Imdad Manik 14
• Define the view of a component
• Contains Html markup and angular directives, attributes etc.
• Describe how a component is rendered on the page
Template
Imdad Manik 15
• A function that adds metadata to a class, class members
• These are prefix with @ symbol
• Angular has built-In decorators like - @Component,
@NgModule, @Directive, @Pipe etc.
Decorators
Imdad Manik 16
• Class decorators
 @NgModule – Used for defining a module
 @Component – Used for defining a component
 @Directive – Used for defining a directive
 @Injectable – Used for injecting dependencies
 @Pipe – Used for defining a pipe
• Class field decorators
 @Input – Used for receiving data (input)
component
 @Output – Used for passing data (events)
component
from parent to child
from child to parent
Types of Decorators
Imdad Manik 17
• Tells Angular how to process a class
• Decorators are used to attach metadata to a class
Metadata
Imdad Manik 18
Data Bindings
String Interpolation: Text is between a set
of curly braces often uses the name of a
component property. The syntax of string
interpolation is to use double curly
braces {{ code }}.
Property Binding: Updating the value of a
certain variable in component (model)
and displaying it in view (presentation
layer).
Imdad Manik 19
Event Binding
• Event Binding: Event binding is defined as the updating/sending of
the value/information of a certain variable from the presentation
layer (view) to the component (model). For example, clicking a
button.
Imdad Manik 20
Routing
Angular Routing allows for
navigation between components
and enables the changing of part
of a page, hence the reasoning
for developing single page
applications. Routing uses the
URL in the address bar to change
components.
Imdad Manik 21
Directive (Types of directives in Angular)
1.Attribute Directive
2.Structural Directive
The basic difference between a component and a
directive is that a component has a template,
whereas an attribute or structural directive does
not have a template. To understand these two
concepts, let us start by creating a simple custom
attribute directive. The directive below changes
the background color of the host element.
Imdad Manik 22
Structural Directive
Structural directives are responsible for HTML layout. They shape
or reshape the DOM's structure, typically by adding, removing, or
manipulating elements.
*ngIf – conditionally includes a template depending on
the value of an expression returned by a Boolean.
*ngFor – makes it simple to iterate over an array.
*ngSwitch – renders each matching view.
Imdad Manik 23
Component Attribute Directive Structural Directives
Component directive
is used to specify the
template/html for
the Dom Layout
Attribute directive is
used to change or
modify the behaviour
of the html element in
the Dom Layout
Structural directive used
to add or remove the
html Element in the Dom
Layout
Built in
@component
Built in
NgStyle,
NgClass
Built in
*NgIf,
*NgFor,
*NgSwitch
Difference between Component, Attribute and Structural Directives?
Imdad Manik 24
Event Emitter
• EventEmitter in Angular is utilized
for communication between
components. Custom events are
emitted from a child component to
its parent component through the
use of EventEmitter.
Imdad Manik 25
Dependency Injection
• Dependency injection (DI) is the part of the Angular
framework that provides components with access to services
and other resources. Angular provides the ability for you to
inject a service into a component to give that component
access to the service.
• Dependency injection is used to make a class independent of
its dependencies or to create a loosely coupled program
Imdad Manik 26
Services
• An essential component of Angular apps is Angular services. They are often used
to group together features like data retrieval, manipulation, and storage that can
be used by several components.
• Moreover, services can be utilized to carry out calculations, implement business
logic, and communicate with external APIs.
• They can be injected into components or other services using the dependency
injection system because they are declared as classes in Angular.
• In order to maintain consistency and avoid memory leaks, Angular services
are singletons which means that there is only one instance of service throughout
the entire application Imdad Manik 27
• ng generate service TodoService
1- Define the service class 3- Add the service to the module
2- Inject the service into a component
Imdad Manik 28
Thank you
• https://www.linkedin.com/in/imdadullah/
• Imdad.khas@hotmail.com
Imdad Manik 29

More Related Content

Similar to Angular Course.pptx

Angular meetup 2 2019-08-29
Angular meetup 2   2019-08-29Angular meetup 2   2019-08-29
Angular meetup 2 2019-08-29Nitin Bhojwani
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2Dor Moshe
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type scriptRavi Mone
 
Foster - Getting started with Angular
Foster - Getting started with AngularFoster - Getting started with Angular
Foster - Getting started with AngularMukundSonaiya1
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshareSaleemMalik52
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupAnsley Rodrigues
 
Angular patterns
Angular patternsAngular patterns
Angular patternsPremkumar M
 
Building Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreBuilding Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreLevi Fuller
 
Building a website with angular 2
Building a website with angular 2Building a website with angular 2
Building a website with angular 2Joseph Jorden
 
Single Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSingle Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSparkhound Inc.
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting startedTejinderMakkar
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesMohamad Al Asmar
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questionsGoa App
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresherRavi Bhadauria
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) PresentationRaghubir Singh
 

Similar to Angular Course.pptx (20)

Angular meetup 2 2019-08-29
Angular meetup 2   2019-08-29Angular meetup 2   2019-08-29
Angular meetup 2 2019-08-29
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
 
Foster - Getting started with Angular
Foster - Getting started with AngularFoster - Getting started with Angular
Foster - Getting started with Angular
 
How Does Angular Work?
How Does Angular Work?How Does Angular Work?
How Does Angular Work?
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setup
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
Building Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreBuilding Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET Core
 
Angular IO
Angular IOAngular IO
Angular IO
 
Building a website with angular 2
Building a website with angular 2Building a website with angular 2
Building a website with angular 2
 
Single Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSingle Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with Angular
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
 
17612235.ppt
17612235.ppt17612235.ppt
17612235.ppt
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresher
 
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 

Angular Course.pptx

  • 1. For Angular Online Training : +91-999 123 502 Introductionto Angular Imdad Manik 1
  • 2. •Angular is written in TypeScript. It implements core and optional functionality as a set of TypeScript libraries that you import into your applications. The architecture of an Angular application relies on certain fundamental concepts. The basic building blocks of the Angular framework are Angular components. Introduction to Angular Imdad Manik 2
  • 3. Angular Environment Setup  Install Node.js which includes Node Package Manager (npm). https://nodejs.org/en/download/  Visual Studio Code. https://code.visualstudio.com/download  Install the Angular CLI globally. npm install -g @angular/cli  Create Project. ng new hello-world cd hello-world  Install project dependencies. npm install  Run the Application. ng serve / npm start Imdad Manik 3
  • 4. Angular CLI Options Options Usage Help ng --help Build ng build --env Build and Run ng serve Testing ng test End-End Testing ng e2e Imdad Manik 4
  • 5. Angular CLI Commands Scaffold Usage In Short Module ng generate module my-module ng g m my-module Component ng generate component my-component ng g c my-component Directive ng generate directive my-directive ng g d my-directive Pipe ng generate pipe my-pipe ng g p my-pipe Service ng generate service my-service ng g s my-service Guard ng generate guard my-guard ng g g my-guard Class ng generate class my-class ng g cl my-class Interface ng generate interface my-interface ng g i my-interface Enum ng generate enum my-enum ng g e my-enum Imdad Manik 5
  • 7. Angular Building Blocks • Modules • Components • Templates • Metadata • Data binding • Directives • Pipes • Routing • Forms • Services • Dependency injection Imdad Manik 7
  • 8. • A module organize an application into unified blocks of functionality • An Angular module is a class with an @NgModule decorator • Accepts a single metadata object whose properties describe the module • Each Angular app must have at least one module, known as root module Modules Imdad Manik 8
  • 10. • imports – Specify other dependent modules whose classes are required by the component templates declared in the module • declarations – Specify the components, directives, and pipes that belong to the module • bootstrap – Specify the main app view i.e root component. Only the root module can have this bootstrap property • exports – A subset of declarations that will be visible and usable in the other modules. A root module doesn’t have export option. • providers – Specify the services, accessible across the app NgModule Metadata Main Properties Imdad Manik 10
  • 11. • Angular has built-In library modules starting with the @angular as prefix • Built-In library & third part modules can be installed using npm manager • Built-In modules, components, services, directives etc. can be imported by using built-In library modules Built-In Modules Imdad Manik 11
  • 12. • A type of directives with template, styles and logic for user interaction • Exported as a custom HTML tag like as:  <my-component></my-component> ng g c my-component Component Imdad Manik 12
  • 13. Angular Components Page View ROOT COMPONENT HEADER COMPONENT FOOTER COMPONENT ARTICLE COMPONENT COMMENTS COMPONENT CATEGORIES COMPONENT NEWS FEEDS COMPONENT Imdad Manik 13
  • 15. • Define the view of a component • Contains Html markup and angular directives, attributes etc. • Describe how a component is rendered on the page Template Imdad Manik 15
  • 16. • A function that adds metadata to a class, class members • These are prefix with @ symbol • Angular has built-In decorators like - @Component, @NgModule, @Directive, @Pipe etc. Decorators Imdad Manik 16
  • 17. • Class decorators  @NgModule – Used for defining a module  @Component – Used for defining a component  @Directive – Used for defining a directive  @Injectable – Used for injecting dependencies  @Pipe – Used for defining a pipe • Class field decorators  @Input – Used for receiving data (input) component  @Output – Used for passing data (events) component from parent to child from child to parent Types of Decorators Imdad Manik 17
  • 18. • Tells Angular how to process a class • Decorators are used to attach metadata to a class Metadata Imdad Manik 18
  • 19. Data Bindings String Interpolation: Text is between a set of curly braces often uses the name of a component property. The syntax of string interpolation is to use double curly braces {{ code }}. Property Binding: Updating the value of a certain variable in component (model) and displaying it in view (presentation layer). Imdad Manik 19
  • 20. Event Binding • Event Binding: Event binding is defined as the updating/sending of the value/information of a certain variable from the presentation layer (view) to the component (model). For example, clicking a button. Imdad Manik 20
  • 21. Routing Angular Routing allows for navigation between components and enables the changing of part of a page, hence the reasoning for developing single page applications. Routing uses the URL in the address bar to change components. Imdad Manik 21
  • 22. Directive (Types of directives in Angular) 1.Attribute Directive 2.Structural Directive The basic difference between a component and a directive is that a component has a template, whereas an attribute or structural directive does not have a template. To understand these two concepts, let us start by creating a simple custom attribute directive. The directive below changes the background color of the host element. Imdad Manik 22
  • 23. Structural Directive Structural directives are responsible for HTML layout. They shape or reshape the DOM's structure, typically by adding, removing, or manipulating elements. *ngIf – conditionally includes a template depending on the value of an expression returned by a Boolean. *ngFor – makes it simple to iterate over an array. *ngSwitch – renders each matching view. Imdad Manik 23
  • 24. Component Attribute Directive Structural Directives Component directive is used to specify the template/html for the Dom Layout Attribute directive is used to change or modify the behaviour of the html element in the Dom Layout Structural directive used to add or remove the html Element in the Dom Layout Built in @component Built in NgStyle, NgClass Built in *NgIf, *NgFor, *NgSwitch Difference between Component, Attribute and Structural Directives? Imdad Manik 24
  • 25. Event Emitter • EventEmitter in Angular is utilized for communication between components. Custom events are emitted from a child component to its parent component through the use of EventEmitter. Imdad Manik 25
  • 26. Dependency Injection • Dependency injection (DI) is the part of the Angular framework that provides components with access to services and other resources. Angular provides the ability for you to inject a service into a component to give that component access to the service. • Dependency injection is used to make a class independent of its dependencies or to create a loosely coupled program Imdad Manik 26
  • 27. Services • An essential component of Angular apps is Angular services. They are often used to group together features like data retrieval, manipulation, and storage that can be used by several components. • Moreover, services can be utilized to carry out calculations, implement business logic, and communicate with external APIs. • They can be injected into components or other services using the dependency injection system because they are declared as classes in Angular. • In order to maintain consistency and avoid memory leaks, Angular services are singletons which means that there is only one instance of service throughout the entire application Imdad Manik 27
  • 28. • ng generate service TodoService 1- Define the service class 3- Add the service to the module 2- Inject the service into a component Imdad Manik 28
  • 29. Thank you • https://www.linkedin.com/in/imdadullah/ • Imdad.khas@hotmail.com Imdad Manik 29