SlideShare a Scribd company logo
1 of 29
Exploring 
Liju Raj Pillai 
CEO, Perfomatix Solutions Pvt Ltd
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 
JAVASCRIPT 
var myModule=angular.module(“myApp”,[]) 
myModule.controller(“exampleController”,[“$scope”,function($scope){ 
$scope.message=“Angular is awesome” 
}]); 
JAVASCRIPT 
var myModule=angular.module(“myApp”,[]) 
myModule.controller(“exampleController”,[“$scope”,function($scope){ 
$scope.message=“Angular is awesome” 
}]); 
HTML 
<html ng-app=“myApp”> 
<head> 
<script src=“lib/angular.js”> 
<script src=“js/___.js”> 
</head> 
<body> 
<div ng-controller=“exampleController”> 
{{message}} 
</div> 
</body> 
</html> 
HTML 
<html ng-app=“myApp”> 
<head> 
<script src=“lib/angular.js”> 
<script src=“js/___.js”> 
</head> 
<body> 
<div ng-controller=“exampleController”> 
{{message}} 
</div> 
</body> 
</html> 
RESULT 
Angular is awesome 
RESULT 
Angular is awesome
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> 
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 
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 behavior to $scope
AngularJS Controllers 
CODE SNIPPET 
var myModule=angular.module(“exampleModule”,[]) 
myModule.controller(“exampleController”,[“$scope”,function($scope){ 
$scope.message=“Angular is awesome” 
}]); 
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> 
HTML 
<div ng-controller="DoubleController"> 
Two times <input ng-model="num"> equals {{ double(num) }} 
</div>
AngularJS $scope 
• Connects controller and view 
• $rootScope
AngularJS $scope 
HTML 
<div ng-controller="MyController"> 
Your name: 
<input type="text" ng-model="username"> 
<button ng-click='sayHello()'>greet</button> 
<hr> 
{{greeting}} 
</div> 
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 + '!'; 
}; 
}]); 
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 
CODE SNIPPET 
var myModule = angular.module('myModule', []); 
myModule.factory('serviceId', function() { 
var shinyNewServiceInstance; 
// factory function body that constructs shinyNewServiceInstance 
return shinyNewServiceInstance; 
}); 
CODE SNIPPET 
var myModule = angular.module('myModule', []); 
myModule.factory('serviceId', function() { 
var shinyNewServiceInstance; 
// factory function body that constructs shinyNewServiceInstance 
return shinyNewServiceInstance; 
});
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); 
}; 
}); 
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.
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
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; 
}); 
}; 
}); 
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> 
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
Demo 
28
Thank you !!! 
29

More Related Content

What's hot

What's hot (20)

Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
Exploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiExploring AngularJS - Liju Pillai
Exploring AngularJS - Liju Pillai
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBDynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
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 
 
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.comWhen to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorial
 
Angular js
Angular jsAngular js
Angular js
 
Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS Introduction
 

Viewers also liked

Viewers also liked (8)

AngularJS Custom Directives
AngularJS Custom DirectivesAngularJS Custom Directives
AngularJS Custom Directives
 
Angular promises and http
Angular promises and httpAngular promises and http
Angular promises and http
 
Angular Promises and Advanced Routing
Angular Promises and Advanced RoutingAngular Promises and Advanced Routing
Angular Promises and Advanced Routing
 
Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
AngularJS custom directive
AngularJS custom directiveAngularJS custom directive
AngularJS custom directive
 
Building AngularJS Custom Directives
Building AngularJS Custom DirectivesBuilding AngularJS Custom Directives
Building AngularJS Custom Directives
 

Similar to Coffee@DBG - Exploring Angular JS

AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
 

Similar to Coffee@DBG - Exploring Angular JS (20)

AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Angularjs
AngularjsAngularjs
Angularjs
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
 
Angular
AngularAngular
Angular
 
Angular
AngularAngular
Angular
 
ANGULAR JS TRAINING IN PUNE
ANGULAR JS TRAINING IN PUNEANGULAR JS TRAINING IN PUNE
ANGULAR JS TRAINING IN PUNE
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
 
Opinionated AngularJS
Opinionated AngularJSOpinionated AngularJS
Opinionated AngularJS
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
Angular - Beginner
Angular - BeginnerAngular - Beginner
Angular - Beginner
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
Ultimate Introduction To AngularJS
Ultimate Introduction To AngularJSUltimate Introduction To AngularJS
Ultimate Introduction To AngularJS
 

More from Deepu S Nath

Greetings & Response - English Communication Training
Greetings & Response - English Communication TrainingGreetings & Response - English Communication Training
Greetings & Response - English Communication Training
Deepu S Nath
 

More from Deepu S Nath (20)

Design Thinking, Critical Thinking & Innovation Design
Design Thinking, Critical Thinking & Innovation DesignDesign Thinking, Critical Thinking & Innovation Design
Design Thinking, Critical Thinking & Innovation Design
 
GTECH ATFG µLearn Framework Intro
GTECH ATFG µLearn Framework IntroGTECH ATFG µLearn Framework Intro
GTECH ATFG µLearn Framework Intro
 
Future of learning - Technology Disruption
Future of learning  - Technology DisruptionFuture of learning  - Technology Disruption
Future of learning - Technology Disruption
 
Decentralized Applications using Ethereum
Decentralized Applications using EthereumDecentralized Applications using Ethereum
Decentralized Applications using Ethereum
 
How machines can take decisions
How machines can take decisionsHow machines can take decisions
How machines can take decisions
 
Artificial Intelligence: An Introduction
 Artificial Intelligence: An Introduction Artificial Intelligence: An Introduction
Artificial Intelligence: An Introduction
 
FAYA PORT 80 Introduction
FAYA PORT 80 IntroductionFAYA PORT 80 Introduction
FAYA PORT 80 Introduction
 
How machines can take decisions
How machines can take decisionsHow machines can take decisions
How machines can take decisions
 
Simplified Introduction to AI
Simplified Introduction to AISimplified Introduction to AI
Simplified Introduction to AI
 
Mining Opportunities of Block Chain and BitCoin
Mining Opportunities of Block Chain and BitCoinMining Opportunities of Block Chain and BitCoin
Mining Opportunities of Block Chain and BitCoin
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
Coffee@DBG - TechBites March 2016
Coffee@DBG - TechBites March 2016Coffee@DBG - TechBites March 2016
Coffee@DBG - TechBites March 2016
 
REACT.JS : Rethinking UI Development Using JavaScript
REACT.JS : Rethinking UI Development Using JavaScriptREACT.JS : Rethinking UI Development Using JavaScript
REACT.JS : Rethinking UI Development Using JavaScript
 
SEO For Developers
SEO For DevelopersSEO For Developers
SEO For Developers
 
Life Cycle of an App - From Idea to Monetization
Life Cycle of an App - From Idea to Monetization  Life Cycle of an App - From Idea to Monetization
Life Cycle of an App - From Idea to Monetization
 
Uncommon Python - What is special in Python
Uncommon Python -  What is special in PythonUncommon Python -  What is special in Python
Uncommon Python - What is special in Python
 
Coffee@DBG - TechBites Sept 2015
Coffee@DBG - TechBites Sept 2015Coffee@DBG - TechBites Sept 2015
Coffee@DBG - TechBites Sept 2015
 
Techbites July 2015
Techbites July 2015Techbites July 2015
Techbites July 2015
 
Apple Watch - Start Your Developer Engine
Apple Watch -  Start Your Developer EngineApple Watch -  Start Your Developer Engine
Apple Watch - Start Your Developer Engine
 
Greetings & Response - English Communication Training
Greetings & Response - English Communication TrainingGreetings & Response - English Communication Training
Greetings & Response - English Communication Training
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Coffee@DBG - Exploring Angular JS

  • 1. Exploring Liju Raj Pillai CEO, Perfomatix Solutions Pvt Ltd
  • 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
  • 8. Sample Application 8 JAVASCRIPT var myModule=angular.module(“myApp”,[]) myModule.controller(“exampleController”,[“$scope”,function($scope){ $scope.message=“Angular is awesome” }]); JAVASCRIPT var myModule=angular.module(“myApp”,[]) myModule.controller(“exampleController”,[“$scope”,function($scope){ $scope.message=“Angular is awesome” }]); HTML <html ng-app=“myApp”> <head> <script src=“lib/angular.js”> <script src=“js/___.js”> </head> <body> <div ng-controller=“exampleController”> {{message}} </div> </body> </html> HTML <html ng-app=“myApp”> <head> <script src=“lib/angular.js”> <script src=“js/___.js”> </head> <body> <div ng-controller=“exampleController”> {{message}} </div> </body> </html> RESULT Angular is awesome RESULT Angular is awesome
  • 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> 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 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 behavior to $scope
  • 15. AngularJS Controllers CODE SNIPPET var myModule=angular.module(“exampleModule”,[]) myModule.controller(“exampleController”,[“$scope”,function($scope){ $scope.message=“Angular is awesome” }]); 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> HTML <div ng-controller="DoubleController"> Two times <input ng-model="num"> equals {{ double(num) }} </div>
  • 16. AngularJS $scope • Connects controller and view • $rootScope
  • 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> 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 + '!'; }; }]); 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 CODE SNIPPET var myModule = angular.module('myModule', []); myModule.factory('serviceId', function() { var shinyNewServiceInstance; // factory function body that constructs shinyNewServiceInstance return shinyNewServiceInstance; }); CODE SNIPPET var myModule = angular.module('myModule', []); myModule.factory('serviceId', function() { var shinyNewServiceInstance; // factory function body that constructs shinyNewServiceInstance return shinyNewServiceInstance; });
  • 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); }; }); 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.
  • 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
  • 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; }); }; }); 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> 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