SlideShare ist ein Scribd-Unternehmen logo
1 von 14
HAPPY
VALENTINES DAY
express your love right here.
Directives & Services
Directives
They teach HTML new tricks
Directives
• Directives is a unique and powerful feature
available only in Angular.
• Directives let you invent your own HTML
syntax, specific to your application.
• Directives can add:
– Behaviors
– Data Binding to scope
– Replace or to extend the HTML element
AngularJS Directives
• Angular comes with a set of these directives
built-in, like ngBind, ngModel, and ngClass.
• Create your own directives for Angular to use.
• What happens for these directives ?
– When Angular bootstraps your application, the
HTML compiler traverses the DOM matching
directives against the DOM elements.
AngularJS Directives
Invoking Directives from HTML
• The directives can be placed in element
names, attributes, class names as well as
comments.
• List of some of the possible directive names
– ng-directivename
– ng:directivename
– ng_directivename
– x-ng-directivename
– data-ng-directivename
Iterating with ng-repeat directive
Iterating with ng-repeat directive
Creating Directives
• To register a directive,
– use the module.directive API.
– module.directive takes the normalized directive name
followed by a factory function. This factory function should
return an object with the different options to tell $compile
how the directive should behave when matched.
• The factory function is invoked only once when the
compiler matches the directive for the first time. You
can perform any initialization work here. The function
is invoked using $injector.invoke which makes it
injectable just like a controller.
Template-expanding directive
• Assume you have a chunk of your template
that represents a customer's information. This
template is repeated many times in your code.
When you change it in one place, you have to
change it in several others. This is a good
opportunity to use a directive to simplify your
template.
Iterating with ng-repeat directive

Weitere ähnliche Inhalte

Was ist angesagt?

AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginnersMunir Hoque
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JSAkshay Mathur
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS introdizabl
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework Sakthi Bro
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project Elad Hirsch
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
 
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.
 

Was ist angesagt? (20)

AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS intro
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Angular js
Angular jsAngular js
Angular js
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
 
Angular js
Angular jsAngular js
Angular js
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
 
Angular JS
Angular JSAngular JS
Angular JS
 
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
 

Ähnlich wie BDOTNET AngularJs Directives - Uday

Angular JS Indtrodution
Angular JS IndtrodutionAngular JS Indtrodution
Angular JS Indtrodutionadesh21
 
Angularjs - custom directives part 05
Angularjs - custom directives part 05Angularjs - custom directives part 05
Angularjs - custom directives part 05Mohd Abdul Baquee
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupGoutam Dey
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJScraftworkz
 
Angular patterns
Angular patternsAngular patterns
Angular patternsPremkumar M
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and conceptsSuresh Patidar
 
Angularjs beginners-workshop1
Angularjs beginners-workshop1Angularjs beginners-workshop1
Angularjs beginners-workshop1Jugnu Sharma
 
Angular js
Angular jsAngular js
Angular jsymtech
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014Sarah Hudson
 
AngularJs Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic ConceptHari Haran
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorialcncwebworld
 

Ähnlich wie BDOTNET AngularJs Directives - Uday (20)

Angular JS Indtrodution
Angular JS IndtrodutionAngular JS Indtrodution
Angular JS Indtrodution
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angularjs - custom directives part 05
Angularjs - custom directives part 05Angularjs - custom directives part 05
Angularjs - custom directives part 05
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
Angularjs
AngularjsAngularjs
Angularjs
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJS
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angularjs basic part01
Angularjs basic part01Angularjs basic part01
Angularjs basic part01
 
Introduction to Angular Js
Introduction to Angular JsIntroduction to Angular Js
Introduction to Angular Js
 
Directives
DirectivesDirectives
Directives
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
 
Angularjs beginners-workshop1
Angularjs beginners-workshop1Angularjs beginners-workshop1
Angularjs beginners-workshop1
 
AngularJS is awesome
AngularJS is awesomeAngularJS is awesome
AngularJS is awesome
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Angular js firebase-preso
Angular js firebase-presoAngular js firebase-preso
Angular js firebase-preso
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
 
AngularJs Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic Concept
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorial
 

Mehr von Udaya Kumar

Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins Udaya Kumar
 
Knockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingKnockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingUdaya Kumar
 
AzureML TechTalk
AzureML TechTalkAzureML TechTalk
AzureML TechTalkUdaya Kumar
 
Innovations and Innovators Prepared by Sharika Shivani U.J
Innovations and Innovators   Prepared by Sharika Shivani U.JInnovations and Innovators   Prepared by Sharika Shivani U.J
Innovations and Innovators Prepared by Sharika Shivani U.JUdaya Kumar
 
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar MathivananHtml5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar MathivananUdaya Kumar
 
KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from ScratchUdaya Kumar
 
Social Reformers Of India Prepared by Sharika Shivani U.J
Social Reformers Of India   Prepared by Sharika Shivani U.JSocial Reformers Of India   Prepared by Sharika Shivani U.J
Social Reformers Of India Prepared by Sharika Shivani U.JUdaya Kumar
 
Html5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar MathivananHtml5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar MathivananUdaya Kumar
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 daysUdaya Kumar
 

Mehr von Udaya Kumar (9)

Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
Knockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingKnockout JS Development - a Quick Understanding
Knockout JS Development - a Quick Understanding
 
AzureML TechTalk
AzureML TechTalkAzureML TechTalk
AzureML TechTalk
 
Innovations and Innovators Prepared by Sharika Shivani U.J
Innovations and Innovators   Prepared by Sharika Shivani U.JInnovations and Innovators   Prepared by Sharika Shivani U.J
Innovations and Innovators Prepared by Sharika Shivani U.J
 
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar MathivananHtml5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
 
KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from Scratch
 
Social Reformers Of India Prepared by Sharika Shivani U.J
Social Reformers Of India   Prepared by Sharika Shivani U.JSocial Reformers Of India   Prepared by Sharika Shivani U.J
Social Reformers Of India Prepared by Sharika Shivani U.J
 
Html5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar MathivananHtml5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar Mathivanan
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 days
 

BDOTNET AngularJs Directives - Uday

  • 3.
  • 5. Directives • Directives is a unique and powerful feature available only in Angular. • Directives let you invent your own HTML syntax, specific to your application. • Directives can add: – Behaviors – Data Binding to scope – Replace or to extend the HTML element
  • 6. AngularJS Directives • Angular comes with a set of these directives built-in, like ngBind, ngModel, and ngClass. • Create your own directives for Angular to use. • What happens for these directives ? – When Angular bootstraps your application, the HTML compiler traverses the DOM matching directives against the DOM elements.
  • 8. Invoking Directives from HTML • The directives can be placed in element names, attributes, class names as well as comments. • List of some of the possible directive names – ng-directivename – ng:directivename – ng_directivename – x-ng-directivename – data-ng-directivename
  • 9.
  • 12. Creating Directives • To register a directive, – use the module.directive API. – module.directive takes the normalized directive name followed by a factory function. This factory function should return an object with the different options to tell $compile how the directive should behave when matched. • The factory function is invoked only once when the compiler matches the directive for the first time. You can perform any initialization work here. The function is invoked using $injector.invoke which makes it injectable just like a controller.
  • 13. Template-expanding directive • Assume you have a chunk of your template that represents a customer's information. This template is repeated many times in your code. When you change it in one place, you have to change it in several others. This is a good opportunity to use a directive to simplify your template.

Hinweis der Redaktion

  1. Static HTML pages to Dynamic HTML pages Angular extend HTML very easily using adding elements,attributes