SlideShare una empresa de Scribd logo
1 de 15
AngularJS Training
Mahmoud shaaban
9/9/2015 AngularJS Training 1
About @Me
• Solution Architect at Mantrac Group
• Skype: Mahmoudfcis
• Twitter: @MahmoodTolba
9/9/2015 AngularJS Training 2
Agenda
Introduction to AngularJS
AngularJS modules
Controllers
Filters and expressions
Directives
Factories
Services
Routing
AngularJS unit testing
9/9/2015 AngularJS Training 3
Introduction to AngularJS
• JavaScript library developed by Google for building dynamics web
apps.
• MV* Framework
• Open source
• Client side
• AngularJS extends vocabulary of HTML
9/9/2015 AngularJS Training 4
AngularJS advantages
• Great framework for building dynamic, SPA web applications
• AngularJS allows you to control complete DOM structure show/hide,
changing everything with AngularJS properties
• Modularity, Support of design patterns, testable framework
• You can accomplish 80% of web application functionality using 20% of
AngularJS features
• AngularJS learning curve is high
• Extensive support and documentation, communities are expanding
• Visual Studio Support and Intellisense
9/9/2015 AngularJS Training 5
AngularJS vs. Other frameworks
• Backbone, Ember, React are another MV* frameworks
9/9/2015 AngularJS Training 6
AngularJS page life cycle
• Bootstrap phase: occurs when the AngularJS library is downloaded to
the browser when the AngularJS initializes its module and its
necessary components, in this phase the module is initialized.
• Compilation phase: occurs when the page is loaded , static form of
the DOM is replaced with dynamic DOM.
• Runtime data binding phase: any changes in the scope reflected in the
view and any changes in the view are reflected in the scope
9/9/2015 AngularJS Training 7
AngularJS Modules
• Is a global place for creating, registering and retrieving Angular
modules
• Is a collection of services, directives, controllers, filters, and
configuration information
• http://ngmodules.org/ custom AngularJS modules
9/9/2015 AngularJS Training 8
Controllers
• They are JS function that binds the view to the Model
• Takes at least one parameter: $scope
• Ng-controller is used to define a controller in a page
• Controllers can be nested with another controllers
• Example HTML:
• Defining the controller in JS
9/9/2015 AngularJS Training 9
<div ng-controller="GreetingController"> {{ greeting }} </div>
var myApp = angular.module('myApp',[]); myApp.controller('DoubleController', ['$scope', function($scope) { $scope.double = function(value) { return value * 2; }; }]);
Expressions
• Angular expressions are JavaScript-like code snippets that are usually
placed in bindings such as {{ expression }}
• Example {{1+2}}
• AngularJS expressions are similar to JavaScript expressions with
several differences; the context of AngularJS expressions is the scope
object whereas the context of JavaScript context window object.
• You cannot write control flow or loop expression inside AngularJS
expression
9/9/2015 AngularJS Training 10
Filters
• A filter formats the value of an expression for display to the user. They can
be used in view templates, controllers or services and it is easy to define
your own filter.
• Built-in AngularJS filters:
9/9/2015 AngularJS Training 11
Filter Description
currency Format a number to a currency format.
filter Select a subset of items from an array.
lowercase Format a string to lower case.
orderBy Orders an array by an expression.
uppercase Format a string to upper case.
• You can build your own filter using module.filter()
Directives
• They are markers on a DOM element (such as an attribute, element
name, comment or CSS class) that tell AngularJS's HTML compiler
($compile) to attach a specified behavior to that DOM element or
even transform the DOM element and its children.
• Add new vocabulary to HTML
• AngularJS comes with plenty of directives ng-app, ng-model, ng-
controller, ng-show, ng-repeat,ng-init
• You can build your custom directive using module.directive()
• Directives can be used for DOM manipulation
9/9/2015 AngularJS Training 12
Factories & Services
• They reusable components that share (business logic, data) across
controllers and directives.
• Angular Services are singletons, only one instance of the service per
injector
• Service syntax : module.service(‘ServiceName’,function); useful for
Shared Utilities
• Factory Syntax: module.factory(‘factoryName’,function);useful for
returning class functions that can be new’ed to create instances
9/9/2015 AngularJS Training 13
Routing
• Use different views for different URL fragments
• Mainly for creating single page applications
• Makes use of template partials
• Templates that are not a whole web page (i.e. part of a page)
• Used in conjunction with the ng-view directive
• ng-view determines where the partial will be placed
• Can only have one ng-view per page
AngularJS Unit Testing
• AngularJS comes with dependency injection built in which makes the
testing easy
• Separation of concerns is important for testing
• Karma and Jasmine are popular testing frameworks for AngularJS
9/9/2015 AngularJS Training 15

Más contenido relacionado

La actualidad más candente

OCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJSOCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJS
Jonathan Meiss
 

La actualidad más candente (20)

AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
AngularJs Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic Concept
 
Angular js for enteprise application
Angular js for enteprise applicationAngular js for enteprise application
Angular js for enteprise application
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
OCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJSOCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJS
 
Introducing angular
Introducing angularIntroducing angular
Introducing angular
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
React or Angular and SharePoint Framework Development
React or Angular and SharePoint Framework DevelopmentReact or Angular and SharePoint Framework Development
React or Angular and SharePoint Framework Development
 
Angular js
Angular jsAngular js
Angular js
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013
 
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 vs React: Building modern SharePoint interfaces with SPFx
Angular vs React: Building modern SharePoint interfaces with SPFxAngular vs React: Building modern SharePoint interfaces with SPFx
Angular vs React: Building modern SharePoint interfaces with SPFx
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
Drupal & AngularJS - DrupalCamp Spain 2014
Drupal & AngularJS - DrupalCamp Spain 2014Drupal & AngularJS - DrupalCamp Spain 2014
Drupal & AngularJS - DrupalCamp Spain 2014
 

Destacado

Javascript Frameworks
Javascript FrameworksJavascript Frameworks
Javascript Frameworks
Mitesh Gandhi
 

Destacado (16)

Conferenza OpenGeoData 2016 - La comunità Open Data Sicilia - Ilaria Vitellio...
Conferenza OpenGeoData 2016 - La comunità Open Data Sicilia - Ilaria Vitellio...Conferenza OpenGeoData 2016 - La comunità Open Data Sicilia - Ilaria Vitellio...
Conferenza OpenGeoData 2016 - La comunità Open Data Sicilia - Ilaria Vitellio...
 
Perfil Investimento Anjo, Julho 2014
Perfil Investimento Anjo, Julho 2014Perfil Investimento Anjo, Julho 2014
Perfil Investimento Anjo, Julho 2014
 
Importancia de las tic en el preescolar
Importancia de las tic en el preescolarImportancia de las tic en el preescolar
Importancia de las tic en el preescolar
 
¿Cómo usar la tecnología para aumentar la venta de viajes?
¿Cómo usar la tecnología para aumentar la venta de viajes?¿Cómo usar la tecnología para aumentar la venta de viajes?
¿Cómo usar la tecnología para aumentar la venta de viajes?
 
Estratégias para Sair da Crise - A Nova Ordem Social e o Cenário Atual
Estratégias para Sair da Crise - A Nova Ordem Social e o Cenário AtualEstratégias para Sair da Crise - A Nova Ordem Social e o Cenário Atual
Estratégias para Sair da Crise - A Nova Ordem Social e o Cenário Atual
 
Mobile app testing
Mobile app testingMobile app testing
Mobile app testing
 
Webshoppers 26
Webshoppers 26Webshoppers 26
Webshoppers 26
 
Angular JS Introduction
Angular JS IntroductionAngular JS Introduction
Angular JS Introduction
 
BeModels - Identidade Visual
BeModels - Identidade VisualBeModels - Identidade Visual
BeModels - Identidade Visual
 
Camila Fontoura - Criação Identidade Visual
Camila Fontoura - Criação Identidade VisualCamila Fontoura - Criação Identidade Visual
Camila Fontoura - Criação Identidade Visual
 
Javascript Frameworks
Javascript FrameworksJavascript Frameworks
Javascript Frameworks
 
Comparatif des frameworks js mv
Comparatif des frameworks js mvComparatif des frameworks js mv
Comparatif des frameworks js mv
 
A History of Ireland, Scotland and Wales - A Course by Dr. Lizabeth Johnson -...
A History of Ireland, Scotland and Wales - A Course by Dr. Lizabeth Johnson -...A History of Ireland, Scotland and Wales - A Course by Dr. Lizabeth Johnson -...
A History of Ireland, Scotland and Wales - A Course by Dr. Lizabeth Johnson -...
 
Introduction à Angular 2
Introduction à Angular 2Introduction à Angular 2
Introduction à Angular 2
 
Morgenbooster #63 | Tools for Insights
Morgenbooster #63 | Tools for InsightsMorgenbooster #63 | Tools for Insights
Morgenbooster #63 | Tools for Insights
 
Morgenbooster #62 | Fighting Monsters
Morgenbooster #62 | Fighting MonstersMorgenbooster #62 | Fighting Monsters
Morgenbooster #62 | Fighting Monsters
 

Similar a AngularJS

Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
Goutam Dey
 

Similar a AngularJS (20)

Angularjs
AngularjsAngularjs
Angularjs
 
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
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
Angular js
Angular jsAngular js
Angular js
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 
Angular JS Indtrodution
Angular JS IndtrodutionAngular JS Indtrodution
Angular JS Indtrodution
 
Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad india
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJS
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
AngularJS is awesome
AngularJS is awesomeAngularJS is awesome
AngularJS is awesome
 
End to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSEnd to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJS
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By Vipin
 
Anjular js
Anjular jsAnjular js
Anjular js
 
What are the key distinctions between Angular and AngularJS?
What are the key distinctions between Angular and AngularJS?What are the key distinctions between Angular and AngularJS?
What are the key distinctions between Angular and AngularJS?
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 

Más de Mahmoud Tolba (10)

The passionate programmer
The passionate programmerThe passionate programmer
The passionate programmer
 
Introduction to SAP, Systems, Applications
Introduction to SAP, Systems, ApplicationsIntroduction to SAP, Systems, Applications
Introduction to SAP, Systems, Applications
 
Developing cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache CordovaDeveloping cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache Cordova
 
JQuery Overview
JQuery OverviewJQuery Overview
JQuery Overview
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
 
ASP.NET MVC controllers
ASP.NET MVC controllersASP.NET MVC controllers
ASP.NET MVC controllers
 
ASP.NET MVC4 Overview
ASP.NET MVC4 OverviewASP.NET MVC4 Overview
ASP.NET MVC4 Overview
 
Top emerging technologies
Top emerging technologiesTop emerging technologies
Top emerging technologies
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 

Último

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Último (20)

WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 

AngularJS

  • 2. About @Me • Solution Architect at Mantrac Group • Skype: Mahmoudfcis • Twitter: @MahmoodTolba 9/9/2015 AngularJS Training 2
  • 3. Agenda Introduction to AngularJS AngularJS modules Controllers Filters and expressions Directives Factories Services Routing AngularJS unit testing 9/9/2015 AngularJS Training 3
  • 4. Introduction to AngularJS • JavaScript library developed by Google for building dynamics web apps. • MV* Framework • Open source • Client side • AngularJS extends vocabulary of HTML 9/9/2015 AngularJS Training 4
  • 5. AngularJS advantages • Great framework for building dynamic, SPA web applications • AngularJS allows you to control complete DOM structure show/hide, changing everything with AngularJS properties • Modularity, Support of design patterns, testable framework • You can accomplish 80% of web application functionality using 20% of AngularJS features • AngularJS learning curve is high • Extensive support and documentation, communities are expanding • Visual Studio Support and Intellisense 9/9/2015 AngularJS Training 5
  • 6. AngularJS vs. Other frameworks • Backbone, Ember, React are another MV* frameworks 9/9/2015 AngularJS Training 6
  • 7. AngularJS page life cycle • Bootstrap phase: occurs when the AngularJS library is downloaded to the browser when the AngularJS initializes its module and its necessary components, in this phase the module is initialized. • Compilation phase: occurs when the page is loaded , static form of the DOM is replaced with dynamic DOM. • Runtime data binding phase: any changes in the scope reflected in the view and any changes in the view are reflected in the scope 9/9/2015 AngularJS Training 7
  • 8. AngularJS Modules • Is a global place for creating, registering and retrieving Angular modules • Is a collection of services, directives, controllers, filters, and configuration information • http://ngmodules.org/ custom AngularJS modules 9/9/2015 AngularJS Training 8
  • 9. Controllers • They are JS function that binds the view to the Model • Takes at least one parameter: $scope • Ng-controller is used to define a controller in a page • Controllers can be nested with another controllers • Example HTML: • Defining the controller in JS 9/9/2015 AngularJS Training 9 <div ng-controller="GreetingController"> {{ greeting }} </div> var myApp = angular.module('myApp',[]); myApp.controller('DoubleController', ['$scope', function($scope) { $scope.double = function(value) { return value * 2; }; }]);
  • 10. Expressions • Angular expressions are JavaScript-like code snippets that are usually placed in bindings such as {{ expression }} • Example {{1+2}} • AngularJS expressions are similar to JavaScript expressions with several differences; the context of AngularJS expressions is the scope object whereas the context of JavaScript context window object. • You cannot write control flow or loop expression inside AngularJS expression 9/9/2015 AngularJS Training 10
  • 11. Filters • A filter formats the value of an expression for display to the user. They can be used in view templates, controllers or services and it is easy to define your own filter. • Built-in AngularJS filters: 9/9/2015 AngularJS Training 11 Filter Description currency Format a number to a currency format. filter Select a subset of items from an array. lowercase Format a string to lower case. orderBy Orders an array by an expression. uppercase Format a string to upper case. • You can build your own filter using module.filter()
  • 12. Directives • They are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element or even transform the DOM element and its children. • Add new vocabulary to HTML • AngularJS comes with plenty of directives ng-app, ng-model, ng- controller, ng-show, ng-repeat,ng-init • You can build your custom directive using module.directive() • Directives can be used for DOM manipulation 9/9/2015 AngularJS Training 12
  • 13. Factories & Services • They reusable components that share (business logic, data) across controllers and directives. • Angular Services are singletons, only one instance of the service per injector • Service syntax : module.service(‘ServiceName’,function); useful for Shared Utilities • Factory Syntax: module.factory(‘factoryName’,function);useful for returning class functions that can be new’ed to create instances 9/9/2015 AngularJS Training 13
  • 14. Routing • Use different views for different URL fragments • Mainly for creating single page applications • Makes use of template partials • Templates that are not a whole web page (i.e. part of a page) • Used in conjunction with the ng-view directive • ng-view determines where the partial will be placed • Can only have one ng-view per page
  • 15. AngularJS Unit Testing • AngularJS comes with dependency injection built in which makes the testing easy • Separation of concerns is important for testing • Karma and Jasmine are popular testing frameworks for AngularJS 9/9/2015 AngularJS Training 15