SlideShare a Scribd company logo
iFour ConsultancyAngular Directives
https://www.ifourtechnolab.com/
Index
❏ Introduction
❏ ngIf
❏ ngFor
❏ ngFor and Trackby
❏ ngSwitchCase
❏ ngClass
❏ ngStyle
https://www.ifourtechnolab.com/
Introduction
❏ There are three kinds of directives in Angular:
❖ Components— directives with a template.
❖ Structural directives— change the DOM layout by adding and removing DOM elements.
❖ Attribute directives— change the appearance or behavior of an element, component, or another
directive.
❏ Structural Directives change the structure of the view. Two examples are NgFor and NgIf.
❏ Structural directives are easy to recognize. An asterisk (*) precedes the directive attribute name as in
this.
❏ Attribute directives are used as attributes of elements. The built-in NgStyle directive in the Template
Syntax guide, for example, can change several element styles at the same time.
https://www.ifourtechnolab.com/
NgIf
❏ <div *ngIf="hero" class="name">{{hero.name}}</div>
❏ No brackets. No parentheses. Just *ngIf set to a string.
❏ The asterisk (*) is a convenience notation and the string is a micro syntax rather than the usual template
expression.
❏ Render to
<ng-template [ngIf]="hero">
<div class="name">{{hero.name}}</div>
</ng-template>
❏ Angular desugars this notation into a marked-up <ng-template> that surrounds the host element and its
descendents. Each structural directive does something different with that template.
❏ Three of the common, built-in structural directives—NgIf, NgFor, and NgSwitch...—are described in the
Template
https://www.ifourtechnolab.com/
NgFor
<ul>
<li *ngFor="let hero of heroes">{{hero.name}}</li>
</ul>
Ref -> https://blog.angular-university.io/angular-2-ngfor/
❏ Angular transforms the *ngFor in similar fashion from asterisk (*) syntax to <ng-template> element.
<div *ngFor="let hero of heroes; let i=index; let odd=odd; trackBy: trackById" [class.odd]="odd">
({{i}}) {{hero.name}}
</div>
<ng-template ngFor let-hero [ngForOf]="heroes" let-i="index" let-odd="odd" [ngForTrackBy]="trackById">
<div [class.odd]="odd">({{i}}) {{hero.name}}</div>
</ng-template>
Angular transforms the *ngFor in similar fashion from asterisk (*) syntax to <ng-template> element.
<div *ngFor="let hero of heroes; let i=index; let odd=odd; trackBy: trackById" [class.odd]="odd">
({{i}}) {{hero.name}}
</div>
<ng-template ngFor let-hero [ngForOf]="heroes" let-i="index" let-odd="odd" [ngForTrackBy]="trackById">
<div [class.odd]="odd">({{i}}) {{hero.name}}</div>
</ng-template>
https://www.ifourtechnolab.com/
NgSwitch
❏ The Angular NgSwitch is actually a set of cooperating directives:
a. NgSwitch,
b. NgSwitchCase, and
c. NgSwitchDefault.
https://www.ifourtechnolab.com/
NgSwitch
❏ The Angular NgSwitch is actually a set of cooperating directives:
a. NgSwitch,
b. NgSwitchCase, and
c. NgSwitchDefault.
<ul [ngSwitch]="person.country">
<li *ngSwitchCase="'UK'" class="text-success">
{{ person.name }} ({{ person.country }})
</li>
<li *ngSwitchCase="'USA'" class="text-primary">
{{ person.name }} ({{ person.country }})
</li>
<li *ngSwitchDefault class="text-warning">
{{ person.name }} ({{ person.country }})
</li>
</ul>
https://www.ifourtechnolab.com/
NgClass
❏ Adds and removes CSS classes on an HTML element.
❏ The CSS classes are updated as follows, depending on the type of the expression evaluation:
a. string - the CSS classes listed in the string (space delimited) are added,
b. Array - the CSS classes declared as Array elements are added,
c. Object - keys are CSS classes that get added when the expression given in the value evaluates to a
truthy value, otherwise they are removed.
<some-element [ngClass]="'first second'">...</some-element>
<some-element [ngClass]="['first', 'second']">...</some-element>
<some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
<some-element [ngClass]="string: Exp|array: Exp|obj: Exp">...</some-element>
<some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
https://www.ifourtechnolab.com/
NgStyle
❏ An attribute directive that updates styles for the containing HTML element.
❏ Sets one or more style properties, specified as colon-separated key-value pairs.
❏ The key is a style name, with an optional .
❏ <unit> suffix (such as 'top.px', 'font-style.em').
❏ The value is an expression to be evaluated.
❏ The resulting non-null value, expressed in the given unit, is assigned to the given style property.
❏ If the result of evaluation is null, the corresponding style is removed.
<some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
<some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
<some-element [ngStyle]="objExp">...</some-element>
https://www.ifourtechnolab.com/
Thank you
https://www.ifourtechnolab.com/

More Related Content

What's hot

Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
Eyal Vardi
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
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.
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
WebStackAcademy
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Duy Khanh
 
Workshop 21: React Router
Workshop 21: React RouterWorkshop 21: React Router
Workshop 21: React Router
Visual Engineering
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
PradeepDyavannanavar
 
Angular Introduction By Surekha Gadkari
Angular Introduction By Surekha GadkariAngular Introduction By Surekha Gadkari
Angular Introduction By Surekha Gadkari
Surekha Gadkari
 
How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...
Katy Slemon
 
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
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
ritika1
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
Laurent Duveau
 
Angular
AngularAngular
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
Rob Eisenberg
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
Eyal Vardi
 
Angular overview
Angular overviewAngular overview
Angular overview
Thanvilahari
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
NAVEENSAGGAM1
 

What's hot (20)

Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Workshop 21: React Router
Workshop 21: React RouterWorkshop 21: React Router
Workshop 21: React Router
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Angular Introduction By Surekha Gadkari
Angular Introduction By Surekha GadkariAngular Introduction By Surekha Gadkari
Angular Introduction By Surekha Gadkari
 
How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...
 
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
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
AngularJS
AngularJS AngularJS
AngularJS
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Angular
AngularAngular
Angular
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Angular overview
Angular overviewAngular overview
Angular overview
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
 

Similar to Angular Directives

Agular 2 - 6 Directives
Agular 2 - 6 DirectivesAgular 2 - 6 Directives
Agular 2 - 6 Directives
Rajneeshksharma
 
Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Eugene Zharkov
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
Gianluca Cacace
 
Building AngularJS Custom Directives
Building AngularJS Custom DirectivesBuilding AngularJS Custom Directives
Building AngularJS Custom Directives
Dan Wahlin
 
Angular
AngularAngular
Angular
LearningTech
 
Angular js recommended practices - mini
Angular js   recommended practices - miniAngular js   recommended practices - mini
Angular js recommended practices - mini
Rasheed Waraich
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...Alessandro Nadalin
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решенияAngular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
Olga Lavrentieva
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
Ran Mizrahi
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
iOS best practices
iOS best practicesiOS best practices
iOS best practices
Maxim Vialyx
 
Angular js
Angular jsAngular js
Angular js
Brian Atkins
 
Angular js
Angular jsAngular js
Angular js
Baldeep Sohal
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
gDayX - Advanced angularjs
gDayX - Advanced angularjsgDayX - Advanced angularjs
gDayX - Advanced angularjsgdgvietnam
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
Dr.Lokesh Gagnani
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
Filip Janevski
 
Discovering Django - zekeLabs
Discovering Django - zekeLabsDiscovering Django - zekeLabs
Discovering Django - zekeLabs
zekeLabs Technologies
 

Similar to Angular Directives (20)

Agular 2 - 6 Directives
Agular 2 - 6 DirectivesAgular 2 - 6 Directives
Agular 2 - 6 Directives
 
Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Angular 2.0: Brighter future?
Angular 2.0: Brighter future?
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Building AngularJS Custom Directives
Building AngularJS Custom DirectivesBuilding AngularJS Custom Directives
Building AngularJS Custom Directives
 
Angular
AngularAngular
Angular
 
Angular
AngularAngular
Angular
 
Angular js recommended practices - mini
Angular js   recommended practices - miniAngular js   recommended practices - mini
Angular js recommended practices - mini
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
 
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решенияAngular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
iOS best practices
iOS best practicesiOS best practices
iOS best practices
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
 
gDayX - Advanced angularjs
gDayX - Advanced angularjsgDayX - Advanced angularjs
gDayX - Advanced angularjs
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Discovering Django - zekeLabs
Discovering Django - zekeLabsDiscovering Django - zekeLabs
Discovering Django - zekeLabs
 

More from iFour Technolab Pvt. Ltd.

Software for Physiotherapists (+Physio) - Final.pdf
Software for Physiotherapists (+Physio) - Final.pdfSoftware for Physiotherapists (+Physio) - Final.pdf
Software for Physiotherapists (+Physio) - Final.pdf
iFour Technolab Pvt. Ltd.
 
Evolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfEvolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdf
iFour Technolab Pvt. Ltd.
 
iFour Technolab - .NET Development Company Profile
iFour Technolab - .NET Development Company ProfileiFour Technolab - .NET Development Company Profile
iFour Technolab - .NET Development Company Profile
iFour Technolab Pvt. Ltd.
 
Java9to19Final.pptx
Java9to19Final.pptxJava9to19Final.pptx
Java9to19Final.pptx
iFour Technolab Pvt. Ltd.
 
Meetup - IoT with Azure behind the scenes 2022.pptx
Meetup - IoT with Azure behind the scenes 2022.pptxMeetup - IoT with Azure behind the scenes 2022.pptx
Meetup - IoT with Azure behind the scenes 2022.pptx
iFour Technolab Pvt. Ltd.
 
LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022
LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022
LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022
iFour Technolab Pvt. Ltd.
 
NFT_Meetup - iFour Technolab.pptx
NFT_Meetup - iFour Technolab.pptxNFT_Meetup - iFour Technolab.pptx
NFT_Meetup - iFour Technolab.pptx
iFour Technolab Pvt. Ltd.
 
Complete WPF Overview Tutorial with Example - iFour Technolab
Complete WPF Overview Tutorial with Example - iFour TechnolabComplete WPF Overview Tutorial with Example - iFour Technolab
Complete WPF Overview Tutorial with Example - iFour Technolab
iFour Technolab Pvt. Ltd.
 
ASP Dot Net Software Development in India - iFour Technolab
ASP Dot Net Software Development in India - iFour TechnolabASP Dot Net Software Development in India - iFour Technolab
ASP Dot Net Software Development in India - iFour Technolab
iFour Technolab Pvt. Ltd.
 
Basic Introduction and Overview of Vue.js
Basic Introduction and Overview of Vue.jsBasic Introduction and Overview of Vue.js
Basic Introduction and Overview of Vue.js
iFour Technolab Pvt. Ltd.
 
Basic Introduction of VSTO Office Add-in Software Development - iFour Technolab
Basic Introduction of VSTO Office Add-in Software Development - iFour TechnolabBasic Introduction of VSTO Office Add-in Software Development - iFour Technolab
Basic Introduction of VSTO Office Add-in Software Development - iFour Technolab
iFour Technolab Pvt. Ltd.
 
Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.
iFour Technolab Pvt. Ltd.
 
Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.
iFour Technolab Pvt. Ltd.
 
Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.
iFour Technolab Pvt. Ltd.
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
Tutorial on Node File System
Tutorial on Node File SystemTutorial on Node File System
Tutorial on Node File System
iFour Technolab Pvt. Ltd.
 
MongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & ExecutionMongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & Execution
iFour Technolab Pvt. Ltd.
 
Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)
iFour Technolab Pvt. Ltd.
 
Agile Project Management with Scrum PDF
Agile Project Management with Scrum PDFAgile Project Management with Scrum PDF
Agile Project Management with Scrum PDF
iFour Technolab Pvt. Ltd.
 
Understanding Agile Development with Scrum
Understanding Agile Development with ScrumUnderstanding Agile Development with Scrum
Understanding Agile Development with Scrum
iFour Technolab Pvt. Ltd.
 

More from iFour Technolab Pvt. Ltd. (20)

Software for Physiotherapists (+Physio) - Final.pdf
Software for Physiotherapists (+Physio) - Final.pdfSoftware for Physiotherapists (+Physio) - Final.pdf
Software for Physiotherapists (+Physio) - Final.pdf
 
Evolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfEvolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdf
 
iFour Technolab - .NET Development Company Profile
iFour Technolab - .NET Development Company ProfileiFour Technolab - .NET Development Company Profile
iFour Technolab - .NET Development Company Profile
 
Java9to19Final.pptx
Java9to19Final.pptxJava9to19Final.pptx
Java9to19Final.pptx
 
Meetup - IoT with Azure behind the scenes 2022.pptx
Meetup - IoT with Azure behind the scenes 2022.pptxMeetup - IoT with Azure behind the scenes 2022.pptx
Meetup - IoT with Azure behind the scenes 2022.pptx
 
LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022
LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022
LAZY IS NEW SMART LET IoT HANDLE IT - Meet UP 2022
 
NFT_Meetup - iFour Technolab.pptx
NFT_Meetup - iFour Technolab.pptxNFT_Meetup - iFour Technolab.pptx
NFT_Meetup - iFour Technolab.pptx
 
Complete WPF Overview Tutorial with Example - iFour Technolab
Complete WPF Overview Tutorial with Example - iFour TechnolabComplete WPF Overview Tutorial with Example - iFour Technolab
Complete WPF Overview Tutorial with Example - iFour Technolab
 
ASP Dot Net Software Development in India - iFour Technolab
ASP Dot Net Software Development in India - iFour TechnolabASP Dot Net Software Development in India - iFour Technolab
ASP Dot Net Software Development in India - iFour Technolab
 
Basic Introduction and Overview of Vue.js
Basic Introduction and Overview of Vue.jsBasic Introduction and Overview of Vue.js
Basic Introduction and Overview of Vue.js
 
Basic Introduction of VSTO Office Add-in Software Development - iFour Technolab
Basic Introduction of VSTO Office Add-in Software Development - iFour TechnolabBasic Introduction of VSTO Office Add-in Software Development - iFour Technolab
Basic Introduction of VSTO Office Add-in Software Development - iFour Technolab
 
Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Case in Legal Industry - iFour Technolab Pvt. Ltd.
 
Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Healthcare Industry - iFour Technolab Pvt. Ltd.
 
Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.
Blockchain Use Cases in Financial Services Industry - iFour Technolab Pvt. Ltd.
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
 
Tutorial on Node File System
Tutorial on Node File SystemTutorial on Node File System
Tutorial on Node File System
 
MongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & ExecutionMongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & Execution
 
Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)Controls Use in Windows Presentation Foundation (WPF)
Controls Use in Windows Presentation Foundation (WPF)
 
Agile Project Management with Scrum PDF
Agile Project Management with Scrum PDFAgile Project Management with Scrum PDF
Agile Project Management with Scrum PDF
 
Understanding Agile Development with Scrum
Understanding Agile Development with ScrumUnderstanding Agile Development with Scrum
Understanding Agile Development with Scrum
 

Recently uploaded

5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer
ofm712785
 
The-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic managementThe-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic management
Bojamma2
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
seoforlegalpillers
 
Brand Analysis for an artist named Struan
Brand Analysis for an artist named StruanBrand Analysis for an artist named Struan
Brand Analysis for an artist named Struan
sarahvanessa51503
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
Operational Excellence Consulting
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
KaiNexus
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
Erika906060
 
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Lviv Startup Club
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
Nicola Wreford-Howard
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
taqyed
 
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdfikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
agatadrynko
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
Aurelien Domont, MBA
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
Lviv Startup Club
 
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdfikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
agatadrynko
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
uae taxgpt
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
LR1709MUSIC
 
Skye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto AirportSkye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto Airport
marketingjdass
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
tjcomstrang
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
Falcon Invoice Discounting
 
Unveiling the Secrets How Does Generative AI Work.pdf
Unveiling the Secrets How Does Generative AI Work.pdfUnveiling the Secrets How Does Generative AI Work.pdf
Unveiling the Secrets How Does Generative AI Work.pdf
Sam H
 

Recently uploaded (20)

5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer5 Things You Need To Know Before Hiring a Videographer
5 Things You Need To Know Before Hiring a Videographer
 
The-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic managementThe-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic management
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
 
Brand Analysis for an artist named Struan
Brand Analysis for an artist named StruanBrand Analysis for an artist named Struan
Brand Analysis for an artist named Struan
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
 
Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)Maksym Vyshnivetskyi: PMO Quality Management (UA)
Maksym Vyshnivetskyi: PMO Quality Management (UA)
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdfikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
 
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdfikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
 
Skye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto AirportSkye Residences | Extended Stay Residences Near Toronto Airport
Skye Residences | Extended Stay Residences Near Toronto Airport
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
 
Unveiling the Secrets How Does Generative AI Work.pdf
Unveiling the Secrets How Does Generative AI Work.pdfUnveiling the Secrets How Does Generative AI Work.pdf
Unveiling the Secrets How Does Generative AI Work.pdf
 

Angular Directives

  • 2. Index ❏ Introduction ❏ ngIf ❏ ngFor ❏ ngFor and Trackby ❏ ngSwitchCase ❏ ngClass ❏ ngStyle https://www.ifourtechnolab.com/
  • 3. Introduction ❏ There are three kinds of directives in Angular: ❖ Components— directives with a template. ❖ Structural directives— change the DOM layout by adding and removing DOM elements. ❖ Attribute directives— change the appearance or behavior of an element, component, or another directive. ❏ Structural Directives change the structure of the view. Two examples are NgFor and NgIf. ❏ Structural directives are easy to recognize. An asterisk (*) precedes the directive attribute name as in this. ❏ Attribute directives are used as attributes of elements. The built-in NgStyle directive in the Template Syntax guide, for example, can change several element styles at the same time. https://www.ifourtechnolab.com/
  • 4. NgIf ❏ <div *ngIf="hero" class="name">{{hero.name}}</div> ❏ No brackets. No parentheses. Just *ngIf set to a string. ❏ The asterisk (*) is a convenience notation and the string is a micro syntax rather than the usual template expression. ❏ Render to <ng-template [ngIf]="hero"> <div class="name">{{hero.name}}</div> </ng-template> ❏ Angular desugars this notation into a marked-up <ng-template> that surrounds the host element and its descendents. Each structural directive does something different with that template. ❏ Three of the common, built-in structural directives—NgIf, NgFor, and NgSwitch...—are described in the Template https://www.ifourtechnolab.com/
  • 5. NgFor <ul> <li *ngFor="let hero of heroes">{{hero.name}}</li> </ul> Ref -> https://blog.angular-university.io/angular-2-ngfor/ ❏ Angular transforms the *ngFor in similar fashion from asterisk (*) syntax to <ng-template> element. <div *ngFor="let hero of heroes; let i=index; let odd=odd; trackBy: trackById" [class.odd]="odd"> ({{i}}) {{hero.name}} </div> <ng-template ngFor let-hero [ngForOf]="heroes" let-i="index" let-odd="odd" [ngForTrackBy]="trackById"> <div [class.odd]="odd">({{i}}) {{hero.name}}</div> </ng-template> Angular transforms the *ngFor in similar fashion from asterisk (*) syntax to <ng-template> element. <div *ngFor="let hero of heroes; let i=index; let odd=odd; trackBy: trackById" [class.odd]="odd"> ({{i}}) {{hero.name}} </div> <ng-template ngFor let-hero [ngForOf]="heroes" let-i="index" let-odd="odd" [ngForTrackBy]="trackById"> <div [class.odd]="odd">({{i}}) {{hero.name}}</div> </ng-template> https://www.ifourtechnolab.com/
  • 6. NgSwitch ❏ The Angular NgSwitch is actually a set of cooperating directives: a. NgSwitch, b. NgSwitchCase, and c. NgSwitchDefault. https://www.ifourtechnolab.com/
  • 7. NgSwitch ❏ The Angular NgSwitch is actually a set of cooperating directives: a. NgSwitch, b. NgSwitchCase, and c. NgSwitchDefault. <ul [ngSwitch]="person.country"> <li *ngSwitchCase="'UK'" class="text-success"> {{ person.name }} ({{ person.country }}) </li> <li *ngSwitchCase="'USA'" class="text-primary"> {{ person.name }} ({{ person.country }}) </li> <li *ngSwitchDefault class="text-warning"> {{ person.name }} ({{ person.country }}) </li> </ul> https://www.ifourtechnolab.com/
  • 8. NgClass ❏ Adds and removes CSS classes on an HTML element. ❏ The CSS classes are updated as follows, depending on the type of the expression evaluation: a. string - the CSS classes listed in the string (space delimited) are added, b. Array - the CSS classes declared as Array elements are added, c. Object - keys are CSS classes that get added when the expression given in the value evaluates to a truthy value, otherwise they are removed. <some-element [ngClass]="'first second'">...</some-element> <some-element [ngClass]="['first', 'second']">...</some-element> <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element> <some-element [ngClass]="string: Exp|array: Exp|obj: Exp">...</some-element> <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element> https://www.ifourtechnolab.com/
  • 9. NgStyle ❏ An attribute directive that updates styles for the containing HTML element. ❏ Sets one or more style properties, specified as colon-separated key-value pairs. ❏ The key is a style name, with an optional . ❏ <unit> suffix (such as 'top.px', 'font-style.em'). ❏ The value is an expression to be evaluated. ❏ The resulting non-null value, expressed in the given unit, is assigned to the given style property. ❏ If the result of evaluation is null, the corresponding style is removed. <some-element [ngStyle]="{'font-style': styleExp}">...</some-element> <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element> <some-element [ngStyle]="objExp">...</some-element> https://www.ifourtechnolab.com/