SlideShare a Scribd company logo
AngularJS
What is AngularJS?
AngularJS is a client-side MVC framework written in JavaScript. It
greatly helps us to write modern, single-page, Ajax-style web
applications.
Although, it is a general purpose framework, but it truly shines
when used with CRUD type applications.
Setting up AngularJS environment
Including AngularJS library
• Download from angularjs.org
• Or use one hosted on Google’s CDN network like so
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/ang
ular.min.js">
</script>
Simple Hello World application
Output
One Way Data Binding
Two Way Data Binding
Extending Hello World
Scopes
• A $scope object in AngularJS is here to expose the domain
model to a view.
• By assigning properties to scope instances, we can make new
values available to a template for rendering.
Getter Functions
<h1> Hello, {{ getName() }} </h1>
Controllers
• Controller is a JavaScript constructor function to initialize scope
objects.
• When a Controller is attached to the DOM via the ng-controller
directive, Angular will instantiate a new Controller object, using
the specified Controller's constructor function. A new child scope
will be available as an injectable parameter to the Controller's
constructor function as $scope.
Use controllers to :
• Set up the initial state of the $scope object.
• Add UI specific behavior to the $scope object.
Model
• AngularJS models are plain, old JavaScript objects.
• Any valid Javascript object or array can be passed to a model.
• To expose a model to AngularJS you simply assign it to a
$scope.
Hierarchy in scopes
• We need to have at least one instance of a scope to create a
new scope because ng-controller directive will create a new
scope using Scope.$new()
• AngularJS has a $rootScope i.e. a parent of all the scopes.
• $rootScope instance gets created when a new application is
bootstrap.
• Scopes are arranged in hierarchical structure which mimic the
DOM tree of the application.
Inheritance
Output
Fetching parent scope using $parent
Rule of thumb
Try to avoid using the $parent property as it strongly links
AngularJS expressions to the DOM structure created by your
tempaltes. An application might break as a result of simple
changes.
Alternative to $parent
Declarative template view – imperative
controller logic
• AngularJS promotes declarative approach to UI construction.
Templates are focused on describing a desired effect rather
than on ways of achieving it.
• It promotes declarative style of programming for templates
and imperative one for JavaScript code (controllers and
business logic)
Modules
Dependency Injection
• In addition to registering objects in a namespace, it is also
possible to declaratively describe dependencies among those
objects.
• It can perform following activities:
 Understand a need for collaborator expressed by objects.
 Wire up objects together into fully –functional application
Dependency Injection ($scope Obj)
Services
Controller example
var myApp = angular.module('myApp',[]);
myApp.controller('GreetingController', ['$scope',
function($scope) {
$scope.greeting = 'Hola!';
}]);
Registering Services
Angular services are substitutable objects that are wired
together using dependency injection (DI). You can use services to
organize and share code across your app.
Service example
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.
Filter example
<div ng-controller="FilterController as ctrl">
<div>
All entries:
<span ng-repeat="entry in ctrl.array">{{entry.name}} </span>
</div>
<div>
Entries that contain an "a":
<span ng-repeat="entry in ctrl.filteredArray">{{entry.name}} </span>
</div>
</div>
angular.module('FilterInControllerModule', []).
controller('FilterController', ['filterFilter', function(filterFilter) {
this.array = [
{name: 'Tobias'},
{name: 'Jeff'},
{name: 'Brian'},
{name: 'Igor'},
{name: 'James'},
{name: 'Brad'}
];
this.filteredArray = filterFilter(this.array, 'a');
}]);
Communicating with Back-end Server
• AngularJS is well equiped with various back-ends using
XMLHttpRequest (XHR) and JSONP requests.
• It has a general purpose $http service for issuing XHR and
JSONP calls as well as a specialized $resource service to easily
target RESTful endpoints.
Making XHP requests with $http
Other XHR request methods
• GET : $http.get(url, config)
• POST : $http.post(url, data, config)
• PUT : $http.put(url, data, config)
• DELETE : $http.delete(url, config)
• HEAD : $http.head
• JSON : $http.jsonp(url, config)
Request/Response data conversion
• The $http.post and $http.put methods accept any JavaScript
object (or a String) value as their data parameter. If data is a
javaScript object it will be by default , converted to a JSON
string.
• The $http service will try to convert responses containg a
JSON string into JavaScript object.
HTTP Response parameters
• Data : The actual response data
• Status : The HTTP status
• Headers : HTTP response headers
• Config : The configurable object that was supplied with
request.
$resource service
• AngularJS provides a dedicated $resource services to make
interactions with REST endpoints.
• The $resource service is distributed in a separate file (angular-
resource.js), and resides in a dedicated module (ngResource).
• To use $resource we need to declare dependency on the
ngResource module from our application.
$resource example
Forms
Controls (input, select, textarea) are ways for a user to enter
data. A Form is a collection of controls for the purpose of
grouping related controls together.
Creating a form
Processing form
Form output
Using CSS classess
• ng-valid: the model is valid
• ng-invalid: the model is invalid
• ng-valid-[key]: for each valid key added by $setValidity
• ng-invalid-[key]: for each invalid key added by $setValidity
• ng-pristine: the control hasn't been interacted with yet
• ng-dirty: the control has been interacted with
• ng-touched: the control has been blurred
• ng-untouched: the control hasn't been blurred
• ng-pending: any $asyncValidators are unfulfilled
Customizing Form UI
<style type="text/css">
.css-form input.ng-invalid.ng-touched {
background-color: #FA787E;
}
.css-form input.ng-valid.ng-touched {
background-color: #78FA89;
}
</style>
Validating an email form field
<div ng-show="form.$submitted || form.uEmail.$touched">
<span ng-show="form.uEmail.$error.required">Tell us your
email.</span>
<span ng-show="form.uEmail.$error.email">This is not a valid
email.</span>
</div>
Why Should We Use AngularJS?
• MVC done right
• A declarative user interface
• Data models are POJO
• Behavior with directives
• Flexibility with filters
• Write less code
• DOM manipulations
• Service providers
• Unit testing ready
• Dynamic binding
Thank You

More Related Content

PPTX
Angular js 1.0-fundamentals
Venkatesh Narayanan
 
PPTX
AngularJS Best Practices
Narek Mamikonyan
 
PPTX
Angular Js Basics
أحمد عبد الوهاب
 
PPTX
Understanding angular js
Aayush Shrestha
 
PPTX
Angular JS
John Temoty Roca
 
PPTX
AngularJS Beginners Workshop
Sathish VJ
 
PPTX
Angular js
Behind D Walls
 
PPTX
Angular js
ParmarAnisha
 
Angular js 1.0-fundamentals
Venkatesh Narayanan
 
AngularJS Best Practices
Narek Mamikonyan
 
Angular Js Basics
أحمد عبد الوهاب
 
Understanding angular js
Aayush Shrestha
 
Angular JS
John Temoty Roca
 
AngularJS Beginners Workshop
Sathish VJ
 
Angular js
Behind D Walls
 
Angular js
ParmarAnisha
 

What's hot (20)

PPTX
Angular js
Dinusha Nandika
 
PPTX
Getting Started with Angular JS
Akshay Mathur
 
PPTX
Angular js
sanjay joshi
 
PPT
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Apaichon Punopas
 
PPTX
Practical AngularJS
Wei Ru
 
PDF
AngularJS Basic Training
Cornel Stefanache
 
PPTX
AngularJS in 60ish Minutes
Dan Wahlin
 
PPTX
The AngularJS way
Boyan Mihaylov
 
PPTX
Angular JS - Introduction
Sagar Acharya
 
PPTX
angularJs Workshop
Ran Wahle
 
PPTX
AngularJS intro
dizabl
 
PPTX
Angular js PPT
Imtiyaz Ahmad Khan
 
PPTX
Angularjs Basics
Anuradha Bandara
 
PPTX
Angular js architecture (v1.4.8)
Gabi Costel Lapusneanu
 
PPTX
Angular JS Indtrodution
adesh21
 
PDF
Angular JS tutorial
cncwebworld
 
PPTX
Angular js for Beginnners
Santosh Kumar Kar
 
PPTX
Angular js for beginners
Munir Hoque
 
PDF
AngularJS Basics
Ravi Mone
 
PPTX
Front end development with Angular JS
Bipin
 
Angular js
Dinusha Nandika
 
Getting Started with Angular JS
Akshay Mathur
 
Angular js
sanjay joshi
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Apaichon Punopas
 
Practical AngularJS
Wei Ru
 
AngularJS Basic Training
Cornel Stefanache
 
AngularJS in 60ish Minutes
Dan Wahlin
 
The AngularJS way
Boyan Mihaylov
 
Angular JS - Introduction
Sagar Acharya
 
angularJs Workshop
Ran Wahle
 
AngularJS intro
dizabl
 
Angular js PPT
Imtiyaz Ahmad Khan
 
Angularjs Basics
Anuradha Bandara
 
Angular js architecture (v1.4.8)
Gabi Costel Lapusneanu
 
Angular JS Indtrodution
adesh21
 
Angular JS tutorial
cncwebworld
 
Angular js for Beginnners
Santosh Kumar Kar
 
Angular js for beginners
Munir Hoque
 
AngularJS Basics
Ravi Mone
 
Front end development with Angular JS
Bipin
 
Ad

Viewers also liked (17)

PDF
NES Global - Life Sciences Brochure 2016
Joe Long
 
PDF
Osha300 a
Isai Serrano
 
PDF
Детский консультативный Центр
damnedney
 
PPTX
піраміда 1
2015aksyonov
 
PPTX
Информационные технологии в деятельности психолога практика: повышение квалиф...
Ilya Perminov
 
PDF
S2017 1. ansøgning Magasin dansk
Henriette Pilegaard
 
PPSX
Print prezent anastassia filatova
Анастасия Филатова
 
PDF
KELEVRAGAMING
Charlie Watson
 
PPT
El planner
Harold Ruiz chumbes
 
PDF
Детский центр на Опарина 4
damnedney
 
PPTX
Evaluation question 7
maxdellimayo
 
PDF
Роды и ведение беременности в научном Центре акушерства, гинекологии и перина...
damnedney
 
PPT
Jihadismo in Libia_Full Version
Elisabetta Benedetti
 
PPTX
Today we explored the sports that children play in Ghana
clarmadd
 
DOCX
J KHAN CV
Jawad Khan
 
NES Global - Life Sciences Brochure 2016
Joe Long
 
Osha300 a
Isai Serrano
 
Детский консультативный Центр
damnedney
 
піраміда 1
2015aksyonov
 
Информационные технологии в деятельности психолога практика: повышение квалиф...
Ilya Perminov
 
S2017 1. ansøgning Magasin dansk
Henriette Pilegaard
 
Print prezent anastassia filatova
Анастасия Филатова
 
KELEVRAGAMING
Charlie Watson
 
Детский центр на Опарина 4
damnedney
 
Evaluation question 7
maxdellimayo
 
Роды и ведение беременности в научном Центре акушерства, гинекологии и перина...
damnedney
 
Jihadismo in Libia_Full Version
Elisabetta Benedetti
 
Today we explored the sports that children play in Ghana
clarmadd
 
J KHAN CV
Jawad Khan
 
Ad

Similar to Angular js (20)

PDF
AngularJS
Hiten Pratap Singh
 
PPTX
Angular workshop - Full Development Guide
Nitin Giri
 
PPT
introduction to Angularjs basics
Ravindra K
 
PPTX
Intoduction to Angularjs
Gaurav Agrawal
 
PDF
AngularJS Workshop
Gianluca Cacace
 
PPSX
Angular js
Arun Somu Panneerselvam
 
PPTX
Angular Presentation
Adam Moore
 
PPTX
Basics of AngularJS
Filip Janevski
 
PPTX
Angularjs
Sabin Tamrakar
 
PPTX
Dive into Angular, part 1: Introduction
Oleksii Prohonnyi
 
PDF
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PPTX
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Jalal Mostafa
 
PDF
Workshop 12: AngularJS Parte I
Visual Engineering
 
PPTX
Introduction to AngularJs
murtazahaveliwala
 
PPTX
Angular Javascript Tutorial with command
ssuser42b933
 
PPTX
Angular Js Get Started - Complete Course
EPAM Systems
 
PPTX
Training On Angular Js
Mahima Radhakrishnan
 
PDF
AngularJS: Overview & Key Features
Mohamad Al Asmar
 
PPTX
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
Angular workshop - Full Development Guide
Nitin Giri
 
introduction to Angularjs basics
Ravindra K
 
Intoduction to Angularjs
Gaurav Agrawal
 
AngularJS Workshop
Gianluca Cacace
 
Angular Presentation
Adam Moore
 
Basics of AngularJS
Filip Janevski
 
Angularjs
Sabin Tamrakar
 
Dive into Angular, part 1: Introduction
Oleksii Prohonnyi
 
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Jalal Mostafa
 
Workshop 12: AngularJS Parte I
Visual Engineering
 
Introduction to AngularJs
murtazahaveliwala
 
Angular Javascript Tutorial with command
ssuser42b933
 
Angular Js Get Started - Complete Course
EPAM Systems
 
Training On Angular Js
Mahima Radhakrishnan
 
AngularJS: Overview & Key Features
Mohamad Al Asmar
 
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 

Recently uploaded (20)

PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
PDF
Winning Business in a Slowing Economy, How CPQ helps Manufacturers Protect Ma...
systemscincom
 
PDF
Comprehensive Salesforce Implementation Services.pdf
VALiNTRY360
 
PPTX
introduction to dart --- Section one .pptx
marknaiem92
 
PDF
Rise With SAP partner in Mumbai.........
pts464036
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
PPTX
10 Hidden App Development Costs That Can Sink Your Startup.pptx
Lunar Web Solution
 
PPTX
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPT
Overview of Oracle Receivables Process.ppt
nbvreddy229
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
PPT
Order to Cash Lifecycle Overview R12 .ppt
nbvreddy229
 
PDF
Exploring AI Agents in Process Industries
amoreira6
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PPTX
Audio Editing and it's techniques in computer graphics.pptx
fosterbayirinia3
 
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
PPT
FALLSEM2025-26_ISWE304L_TH_VL2025260102786_2025-07-10_Reference-Material-II.ppt
AKSHAYA255427
 
DOCX
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
PPTX
Benefits of DCCM for Genesys Contact Center
pointel ivr
 
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
Winning Business in a Slowing Economy, How CPQ helps Manufacturers Protect Ma...
systemscincom
 
Comprehensive Salesforce Implementation Services.pdf
VALiNTRY360
 
introduction to dart --- Section one .pptx
marknaiem92
 
Rise With SAP partner in Mumbai.........
pts464036
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
10 Hidden App Development Costs That Can Sink Your Startup.pptx
Lunar Web Solution
 
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Overview of Oracle Receivables Process.ppt
nbvreddy229
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
Order to Cash Lifecycle Overview R12 .ppt
nbvreddy229
 
Exploring AI Agents in Process Industries
amoreira6
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Audio Editing and it's techniques in computer graphics.pptx
fosterbayirinia3
 
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
FALLSEM2025-26_ISWE304L_TH_VL2025260102786_2025-07-10_Reference-Material-II.ppt
AKSHAYA255427
 
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
Benefits of DCCM for Genesys Contact Center
pointel ivr
 

Angular js

  • 2. What is AngularJS? AngularJS is a client-side MVC framework written in JavaScript. It greatly helps us to write modern, single-page, Ajax-style web applications. Although, it is a general purpose framework, but it truly shines when used with CRUD type applications.
  • 3. Setting up AngularJS environment Including AngularJS library • Download from angularjs.org • Or use one hosted on Google’s CDN network like so <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/ang ular.min.js"> </script>
  • 4. Simple Hello World application
  • 6. One Way Data Binding
  • 7. Two Way Data Binding
  • 9. Scopes • A $scope object in AngularJS is here to expose the domain model to a view. • By assigning properties to scope instances, we can make new values available to a template for rendering.
  • 10. Getter Functions <h1> Hello, {{ getName() }} </h1>
  • 11. Controllers • Controller is a JavaScript constructor function to initialize scope objects. • When a Controller is attached to the DOM via the ng-controller directive, Angular will instantiate a new Controller object, using the specified Controller's constructor function. A new child scope will be available as an injectable parameter to the Controller's constructor function as $scope.
  • 12. Use controllers to : • Set up the initial state of the $scope object. • Add UI specific behavior to the $scope object.
  • 13. Model • AngularJS models are plain, old JavaScript objects. • Any valid Javascript object or array can be passed to a model. • To expose a model to AngularJS you simply assign it to a $scope.
  • 14. Hierarchy in scopes • We need to have at least one instance of a scope to create a new scope because ng-controller directive will create a new scope using Scope.$new() • AngularJS has a $rootScope i.e. a parent of all the scopes. • $rootScope instance gets created when a new application is bootstrap. • Scopes are arranged in hierarchical structure which mimic the DOM tree of the application.
  • 17. Fetching parent scope using $parent
  • 18. Rule of thumb Try to avoid using the $parent property as it strongly links AngularJS expressions to the DOM structure created by your tempaltes. An application might break as a result of simple changes.
  • 20. Declarative template view – imperative controller logic • AngularJS promotes declarative approach to UI construction. Templates are focused on describing a desired effect rather than on ways of achieving it. • It promotes declarative style of programming for templates and imperative one for JavaScript code (controllers and business logic)
  • 22. Dependency Injection • In addition to registering objects in a namespace, it is also possible to declaratively describe dependencies among those objects. • It can perform following activities:  Understand a need for collaborator expressed by objects.  Wire up objects together into fully –functional application
  • 25. Controller example var myApp = angular.module('myApp',[]); myApp.controller('GreetingController', ['$scope', function($scope) { $scope.greeting = 'Hola!'; }]);
  • 26. Registering Services Angular services are substitutable objects that are wired together using dependency injection (DI). You can use services to organize and share code across your app.
  • 28. 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.
  • 29. Filter example <div ng-controller="FilterController as ctrl"> <div> All entries: <span ng-repeat="entry in ctrl.array">{{entry.name}} </span> </div> <div> Entries that contain an "a": <span ng-repeat="entry in ctrl.filteredArray">{{entry.name}} </span> </div> </div>
  • 30. angular.module('FilterInControllerModule', []). controller('FilterController', ['filterFilter', function(filterFilter) { this.array = [ {name: 'Tobias'}, {name: 'Jeff'}, {name: 'Brian'}, {name: 'Igor'}, {name: 'James'}, {name: 'Brad'} ]; this.filteredArray = filterFilter(this.array, 'a'); }]);
  • 31. Communicating with Back-end Server • AngularJS is well equiped with various back-ends using XMLHttpRequest (XHR) and JSONP requests. • It has a general purpose $http service for issuing XHR and JSONP calls as well as a specialized $resource service to easily target RESTful endpoints.
  • 32. Making XHP requests with $http
  • 33. Other XHR request methods • GET : $http.get(url, config) • POST : $http.post(url, data, config) • PUT : $http.put(url, data, config) • DELETE : $http.delete(url, config) • HEAD : $http.head • JSON : $http.jsonp(url, config)
  • 34. Request/Response data conversion • The $http.post and $http.put methods accept any JavaScript object (or a String) value as their data parameter. If data is a javaScript object it will be by default , converted to a JSON string. • The $http service will try to convert responses containg a JSON string into JavaScript object.
  • 35. HTTP Response parameters • Data : The actual response data • Status : The HTTP status • Headers : HTTP response headers • Config : The configurable object that was supplied with request.
  • 36. $resource service • AngularJS provides a dedicated $resource services to make interactions with REST endpoints. • The $resource service is distributed in a separate file (angular- resource.js), and resides in a dedicated module (ngResource). • To use $resource we need to declare dependency on the ngResource module from our application.
  • 38. Forms Controls (input, select, textarea) are ways for a user to enter data. A Form is a collection of controls for the purpose of grouping related controls together.
  • 42. Using CSS classess • ng-valid: the model is valid • ng-invalid: the model is invalid • ng-valid-[key]: for each valid key added by $setValidity • ng-invalid-[key]: for each invalid key added by $setValidity • ng-pristine: the control hasn't been interacted with yet • ng-dirty: the control has been interacted with • ng-touched: the control has been blurred • ng-untouched: the control hasn't been blurred • ng-pending: any $asyncValidators are unfulfilled
  • 43. Customizing Form UI <style type="text/css"> .css-form input.ng-invalid.ng-touched { background-color: #FA787E; } .css-form input.ng-valid.ng-touched { background-color: #78FA89; } </style>
  • 44. Validating an email form field <div ng-show="form.$submitted || form.uEmail.$touched"> <span ng-show="form.uEmail.$error.required">Tell us your email.</span> <span ng-show="form.uEmail.$error.email">This is not a valid email.</span> </div>
  • 45. Why Should We Use AngularJS? • MVC done right • A declarative user interface • Data models are POJO • Behavior with directives • Flexibility with filters • Write less code • DOM manipulations • Service providers • Unit testing ready • Dynamic binding