SlideShare une entreprise Scribd logo
1  sur  28
When to use and when not to use
Liju Raj Pillai
www.perfomatix.com
?
2
Topics
• What to expect from the talk
• Why JavaScript is relevant?
• Before diving in to AngularJS
• What is AngularJS
• Core concepts of AngularJS
• When to use AngularJS
• What next
• Demo
3
What to expect from this talk?
Why JS is relevant ?
• JavaScript is around since 1995
• Considered to be “second class”
• Ajax
• jQuery,underscore
• Modern browsers
• Better JS engines
Before diving in to AngularJS
• JavaScript(of course !!!)
• Model View Controller pattern
• Why MVC ?
• Server side MVC
• Client side MVC
• SPA – Single Page Application
• Framework vs Library
What is AngularJS
• Client-side framework
• Developed and maintained by Google.
• Provides client side MVC capabilities.
• Philosophy
• Declarative code is better than imperative
• Testing in equal importance to app writing
• Decouple client side from server side
• Ideal for SPA
Sample Application
8
AngularJS Hello World
Modules
• Divides web application into small,reusable components
• Controllers,Filters,Directives etc can be declared inside a module
• You can package code as reusable modules
• Modules can be loaded in any order
• Unit tests only have to load relevant modules
Modules
CREATING AN ANGULAR JS MODULE
<script type="text/javascript">
angular.module('myApp',[]);
angular.module('myApp',['dependentModule1','dependentModule2'])
;
</script>
USING ANGULAR JS MODULE
<html ng-app="myApp">
<head>...</head>
<body>…</body>
</html
Data Binding
Data Binding in Classical Template
Systems
Data Binding in Angular Templates
Dependency Injection
• Design pattern
• DI is omnipresent in AngularJS
Dependency Injection
AngularJS Controllers
• Where your business logic lives
• Layer between UI and data store
• ng-controller
• Decoupled from the view
• Re-instantiated on every new call
• Add behaviour to $scope
AngularJS Controllers
CODE SNIPPET
var myModule=angular.module(“exampleModule”,[])
myModule.controller(“exampleController”,[“$scope”,function($scope){
$scope.message=“Angular is awesome”
}]);
HTML
<div ng-controller="DoubleController">
Two times <input ng-model="num"> equals {{ double(num) }}
</div>
Controller Fiddle
AngularJS $scope
• Connects controller and view
• $rootScope
• Example Fiddle
AngularJS $scope
HTML
<div ng-controller="MyController">
Your name:
<input type="text" ng-model="username">
<button ng-click='sayHello()'>greet</button>
<hr>
{{greeting}}
</div>
SCRIPT
angular.module('scopeExample', [])
.controller('MyController', ['$scope', function($scope) {
$scope.username = 'World';
$scope.sayHello = function() {
$scope.greeting = 'Hello ' + $scope.username + '!';
};
}]);
AngularJS Service
• Stateless objects that contains useful function
• Can be called from controllers,filters,directives etc
• Singleton
• Injectable by DI
• Reusable components
AngularJS Service
• Lazy instantiated
• Services provided by Angular
• $http - For ajax requests
• $interval and $timeout - Repeats and delays
• $rootScope - very top scope of application
• $location - URL and its parts of current site
• $window - Wrapper of global window. Useful for tests
• Example
AngularJS Filters
• A filter formats the value of an expression for display to the user
CODE SNIPPET
myApp.filter('capitalize', function () {
return function (s) {
if (!s || !angular.isString(s)) {
return s;
}
return s.charAt(0).toUpperCase() + s.substring(1);
};
});
AngularJS Filters
• Functions which modify expressions
• But does not alter the original data
• Angular JS provides few of its own filters
• currency,lowercase,date,number,filter,orderBy,uppercase etc
• Example
AngularJS Directives
• Angular’s way to teach html new tricks
• Lives in the view
• Built in Directives ng-app, ng-controller, ng-repeat, ng-model etc
• Directive names, ngModel or ng-model
• Example
AngularJS Directives
JAVASCRIPT
myApp.directive('boldClick', function() {
return function(scope, element) {
var bold = false;
element.click(function() {
if (bold) {
element.css('font-weight', 'normal');
} else {
element.css('font-weight', 'bold');
}
bold = !bold;
});
};
});
HTML
<div>
My pet is a <span bold-click>tortoise</span>.
</div>
https://docs.angularjs.org/api/ng/directive
When to use AngularJS
• CRUD Application
• SPA
• API First
When not to use AngularJS
• Games
• GUI Editors
• Applications with intensive and tricky DOM manipulation
• Non SPA applications
What next
• Path from novice to ninja
• Learn JavaScript http://eloquentjavascript.net/
• Read https://docs.angularjs.org/guide
• Do https://docs.angularjs.org/tutorial
• Refer https://egghead.io/
What next
• Angular2.0
• Tools
• http://yeoman.io/ - Scaffolding and build tool
• batarang - Debug tool
Thank you !!!
28

Contenu connexe

Tendances

Zend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applicationsZend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applications
Etisbew Technology Group
 

Tendances (20)

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 - 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 
 
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 Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic Concept
 
MVC with Zend Framework
MVC with Zend FrameworkMVC with Zend Framework
MVC with Zend Framework
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Introduction to SPA with AngularJS
Introduction to SPA with AngularJSIntroduction to SPA with AngularJS
Introduction to SPA with AngularJS
 
Spa with angular
Spa with angularSpa with angular
Spa with angular
 
Require js
Require jsRequire js
Require js
 
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
 
Zend framework 02 - mvc
Zend framework 02 - mvcZend framework 02 - mvc
Zend framework 02 - mvc
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0Introduction to Angular js 2.0
Introduction to Angular js 2.0
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend Framework
 
Intro to UI-Router/TypeScript
Intro to UI-Router/TypeScriptIntro to UI-Router/TypeScript
Intro to UI-Router/TypeScript
 
Zend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applicationsZend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applications
 
Require JS
Require JSRequire JS
Require JS
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
AngularJS
AngularJSAngularJS
AngularJS
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
 

Similaire à When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com

Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
Ganesh Kondal
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
Goutam Dey
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
 

Similaire à When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com (20)

Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
Angularjs
AngularjsAngularjs
Angularjs
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJS
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
 
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
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Angular js
Angular jsAngular js
Angular js
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 

Plus de Perfomatix Solutions

Plus de Perfomatix Solutions (19)

Social events listing platform.pptx
Social events listing platform.pptxSocial events listing platform.pptx
Social events listing platform.pptx
 
Virtual Trial Room for Jewellery Retailers_.pptx
Virtual Trial Room for Jewellery Retailers_.pptxVirtual Trial Room for Jewellery Retailers_.pptx
Virtual Trial Room for Jewellery Retailers_.pptx
 
Real-time Customer Interaction Analytics_.pptx
Real-time Customer Interaction Analytics_.pptxReal-time Customer Interaction Analytics_.pptx
Real-time Customer Interaction Analytics_.pptx
 
Online Tutoring System _With _Content Management.pptx
Online Tutoring System _With _Content Management.pptxOnline Tutoring System _With _Content Management.pptx
Online Tutoring System _With _Content Management.pptx
 
Online Social Networking Platform for Farmers_.pptx
Online Social Networking Platform for Farmers_.pptxOnline Social Networking Platform for Farmers_.pptx
Online Social Networking Platform for Farmers_.pptx
 
Workforce Management Platform.pptx
Workforce Management Platform.pptxWorkforce Management Platform.pptx
Workforce Management Platform.pptx
 
Digital Wealth Management Platform.pptx
Digital Wealth Management Platform.pptxDigital Wealth Management Platform.pptx
Digital Wealth Management Platform.pptx
 
AR Powered Branding and Promotions_.pptx
AR Powered Branding and Promotions_.pptxAR Powered Branding and Promotions_.pptx
AR Powered Branding and Promotions_.pptx
 
Online Free Image Editing Tool.pptx
Online Free Image Editing Tool.pptxOnline Free Image Editing Tool.pptx
Online Free Image Editing Tool.pptx
 
IOT-Powered System for TV Viewing Insights.pptx
IOT-Powered System for TV Viewing Insights.pptxIOT-Powered System for TV Viewing Insights.pptx
IOT-Powered System for TV Viewing Insights.pptx
 
E-Commerce mobile app builder.pdf
E-Commerce mobile app builder.pdfE-Commerce mobile app builder.pdf
E-Commerce mobile app builder.pdf
 
Inventory Management Platform for SIM Cards.pptx
Inventory Management Platform for SIM Cards.pptxInventory Management Platform for SIM Cards.pptx
Inventory Management Platform for SIM Cards.pptx
 
Artificial Intelligence Powered Event Monitoring_4-11-2022.pptx
Artificial Intelligence Powered Event Monitoring_4-11-2022.pptxArtificial Intelligence Powered Event Monitoring_4-11-2022.pptx
Artificial Intelligence Powered Event Monitoring_4-11-2022.pptx
 
Smart Water Meter Powered by Internet of Things [Client Case Study]
Smart Water Meter Powered by Internet of Things [Client Case Study]Smart Water Meter Powered by Internet of Things [Client Case Study]
Smart Water Meter Powered by Internet of Things [Client Case Study]
 
Aggregator Platform for Professional Services [Client Case Study]
Aggregator Platform for Professional Services [Client Case Study]Aggregator Platform for Professional Services [Client Case Study]
Aggregator Platform for Professional Services [Client Case Study]
 
Social Media Analytics Dashboard [Client Case Study]
Social Media Analytics Dashboard [Client Case Study]Social Media Analytics Dashboard [Client Case Study]
Social Media Analytics Dashboard [Client Case Study]
 
Performance Management System - Perfomatix Client Case Study
Performance Management System - Perfomatix Client Case StudyPerformance Management System - Perfomatix Client Case Study
Performance Management System - Perfomatix Client Case Study
 
Intelligent Personal Virtual Assistant for Learning - Perfomatix Case Study
Intelligent Personal Virtual Assistant for Learning - Perfomatix Case StudyIntelligent Personal Virtual Assistant for Learning - Perfomatix Case Study
Intelligent Personal Virtual Assistant for Learning - Perfomatix Case Study
 
When to build a hybrid mobile application? Liju Pillai, www.perfomatix.com
When to build a hybrid mobile application? Liju Pillai, www.perfomatix.comWhen to build a hybrid mobile application? Liju Pillai, www.perfomatix.com
When to build a hybrid mobile application? Liju Pillai, www.perfomatix.com
 

Dernier

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Dernier (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com

  • 1. When to use and when not to use Liju Raj Pillai www.perfomatix.com ?
  • 2. 2
  • 3. Topics • What to expect from the talk • Why JavaScript is relevant? • Before diving in to AngularJS • What is AngularJS • Core concepts of AngularJS • When to use AngularJS • What next • Demo 3
  • 4. What to expect from this talk?
  • 5. Why JS is relevant ? • JavaScript is around since 1995 • Considered to be “second class” • Ajax • jQuery,underscore • Modern browsers • Better JS engines
  • 6. Before diving in to AngularJS • JavaScript(of course !!!) • Model View Controller pattern • Why MVC ? • Server side MVC • Client side MVC • SPA – Single Page Application • Framework vs Library
  • 7. What is AngularJS • Client-side framework • Developed and maintained by Google. • Provides client side MVC capabilities. • Philosophy • Declarative code is better than imperative • Testing in equal importance to app writing • Decouple client side from server side • Ideal for SPA
  • 9. Modules • Divides web application into small,reusable components • Controllers,Filters,Directives etc can be declared inside a module • You can package code as reusable modules • Modules can be loaded in any order • Unit tests only have to load relevant modules
  • 10. Modules CREATING AN ANGULAR JS MODULE <script type="text/javascript"> angular.module('myApp',[]); angular.module('myApp',['dependentModule1','dependentModule2']) ; </script> USING ANGULAR JS MODULE <html ng-app="myApp"> <head>...</head> <body>…</body> </html
  • 11. Data Binding Data Binding in Classical Template Systems Data Binding in Angular Templates
  • 12. Dependency Injection • Design pattern • DI is omnipresent in AngularJS
  • 14. AngularJS Controllers • Where your business logic lives • Layer between UI and data store • ng-controller • Decoupled from the view • Re-instantiated on every new call • Add behaviour to $scope
  • 15. AngularJS Controllers CODE SNIPPET var myModule=angular.module(“exampleModule”,[]) myModule.controller(“exampleController”,[“$scope”,function($scope){ $scope.message=“Angular is awesome” }]); HTML <div ng-controller="DoubleController"> Two times <input ng-model="num"> equals {{ double(num) }} </div> Controller Fiddle
  • 16. AngularJS $scope • Connects controller and view • $rootScope • Example Fiddle
  • 17. AngularJS $scope HTML <div ng-controller="MyController"> Your name: <input type="text" ng-model="username"> <button ng-click='sayHello()'>greet</button> <hr> {{greeting}} </div> SCRIPT angular.module('scopeExample', []) .controller('MyController', ['$scope', function($scope) { $scope.username = 'World'; $scope.sayHello = function() { $scope.greeting = 'Hello ' + $scope.username + '!'; }; }]);
  • 18. AngularJS Service • Stateless objects that contains useful function • Can be called from controllers,filters,directives etc • Singleton • Injectable by DI • Reusable components
  • 19. AngularJS Service • Lazy instantiated • Services provided by Angular • $http - For ajax requests • $interval and $timeout - Repeats and delays • $rootScope - very top scope of application • $location - URL and its parts of current site • $window - Wrapper of global window. Useful for tests • Example
  • 20. AngularJS Filters • A filter formats the value of an expression for display to the user CODE SNIPPET myApp.filter('capitalize', function () { return function (s) { if (!s || !angular.isString(s)) { return s; } return s.charAt(0).toUpperCase() + s.substring(1); }; });
  • 21. AngularJS Filters • Functions which modify expressions • But does not alter the original data • Angular JS provides few of its own filters • currency,lowercase,date,number,filter,orderBy,uppercase etc • Example
  • 22. AngularJS Directives • Angular’s way to teach html new tricks • Lives in the view • Built in Directives ng-app, ng-controller, ng-repeat, ng-model etc • Directive names, ngModel or ng-model • Example
  • 23. AngularJS Directives JAVASCRIPT myApp.directive('boldClick', function() { return function(scope, element) { var bold = false; element.click(function() { if (bold) { element.css('font-weight', 'normal'); } else { element.css('font-weight', 'bold'); } bold = !bold; }); }; }); HTML <div> My pet is a <span bold-click>tortoise</span>. </div> https://docs.angularjs.org/api/ng/directive
  • 24. When to use AngularJS • CRUD Application • SPA • API First
  • 25. When not to use AngularJS • Games • GUI Editors • Applications with intensive and tricky DOM manipulation • Non SPA applications
  • 26. What next • Path from novice to ninja • Learn JavaScript http://eloquentjavascript.net/ • Read https://docs.angularjs.org/guide • Do https://docs.angularjs.org/tutorial • Refer https://egghead.io/
  • 27. What next • Angular2.0 • Tools • http://yeoman.io/ - Scaffolding and build tool • batarang - Debug tool