SlideShare a Scribd company logo
- Priyanka Bachu
ANGULAR JS
1. Introduction to AngularJS
2. Controllers & Views
3. Services
4. Filters
5. Routing
6. Directives
AGENDA
A JavaScript framework for creating dynamic web
applications
INTRODUCTION TO ANGULARJS
• Model
The data
• Controller
The behavior
Modifying / updating the models
• View
The interface
How the data is presented to the user
ARCHITECTURE
• Views are declarative
The structure of the interface
• Controllers do not need to directly manipulate the view
Changes in the models / data are automatically
reflected in the view
Updates are managed by the frameworks
CONTROLLERS AND VIEWS
• Make use of special ng attributes (directives) on the
HTML elements
ng-app
• Determines which part of the page will use AngularJS
• If given a value it will load that application module
ng-controller
• Determines which Javascript Controller should be used for that part
of the page
ng-model
• Determines what model the value of an input field will be bound to
• Used for two-way binding
CONTROLLERS AND VIEWS
• More ng directives
ngSwitch=<ANY ng-switch="expression">
<ANY ng-switch-when="matchValue1"></ANY>
<ANY ng-switch-when="matchValue2"></ANY>
<ANY ng-switch-default>...</ANY> </ANY>
ng-if=“<model expression>”
• Inserts HTML element if expression is true
• Does not insert element in the DOM if it is false
ng-repeat=“<variable> in <array>”
• Repeats the HTML element for each value in the array
• Also a key-value pair version for JSON objects
“(<key>, <value>) in <JSON>”
CONTROLLERS AND VIEWS
<div ng-app="" ng-controller="personController">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
</div>
<script>
function personController($scope) {
$scope.firstName = "John",
$scope.lastName = "Doe"
}
</script>
CONTROLLERS AND VIEWS
$q
A service that helps you run functions asynchronously, and use their return values (or exceptions)
when they are done processing.
$http.get('/api/v1/movies/avengers')
.success(function(data, status, headers, config) {
$scope.movieContent = data;
});
// is the same as
var promise = $http.get('/api/v1/movies/avengers');
promise.then(
function(payload) {
$scope.movieContent = payload.data;
})
SERVICES
module.factory(‘factory_id’, function() {
return {
functionname: function() {
return “this is a function”;
},
anotherfunction: function() {
// make a request and get data from backend
return data;
}
}
});
FACTORY
• Reusable operation using which you can modify the
content that is shown on the page
• Examples: uppercase a value, filter search results, etc.
module.filter(“filter_name”, function(data) {
// data is filtered or modified in a
//specific manner and returned
return data;
}
FILTERS
• Use different views for different URL fragments
• 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
ROUTING
• URL parameters
To access the parameters in the URL, use the
$routeParams service
The $routeParams object will have a field with the same
name as the parameter
Ex.
• $routeParams.userId
ROUTE PARAMS
• URL parameters
To access the parameters in the URL, use the
$routeParams service
The $routeParams object will have a field with the same
name as the parameter
Ex.
• $routeParams.userId
ROUTE PARAMS
DIRECTIVES
app.directive('ngSparkline', function() {
return {
restrict: 'A',
require: '^ngCity',
scope: {
ngCity: '@'
},
template: '<div class="sparkline"><h4>Weather for {{ngCity}}</h4></div>',
controller: ['$scope', '$http', function($scope, $http) {
$scope.getTemp = function(city) {}
}],
link: function(scope, iElement, iAttrs, ctrl) {
scope.getTemp(iAttrs.ngCity);
}
}
});
CUSTOM DIRECTIVES
Raisers:
$broadcast(parent scope to child scope)
$emit(child scope to parent scope)
Listeners
$on
EVENTS
'use strict';
angular.module('myAppControllers', [])
.controller('FirstCtrl', function ($scope) {
$scope.$broadcast('UPDATE_CHILD');
})
.controller('SecondCtrl', function ($scope) {
$scope.$on('UPDATE_CHILD', function() {
// do something useful here;
});
})
EXAMPLE
Angular js

More Related Content

PPTX
Introduction to Ember.js
PDF
Introduction of angular js
PDF
Who's afraid of front end databases
PPTX
EmberJS BucharestJS
PPTX
Angular js presentation at Datacom
PDF
Angular Classy
PPTX
Angular JS Indtrodution
PPTX
Redux in Angular2 for jsbe
Introduction to Ember.js
Introduction of angular js
Who's afraid of front end databases
EmberJS BucharestJS
Angular js presentation at Datacom
Angular Classy
Angular JS Indtrodution
Redux in Angular2 for jsbe

What's hot (20)

PPTX
Why angular js Framework
PPTX
AngularJs (1.x) Presentation
PPTX
AngularJS Best Practices
PPTX
Angular JS - Introduction
PPT
Angular js
PPTX
Angular js 1.0-fundamentals
PPTX
Spring mvc
PDF
前后端mvc经验 - webrebuild 2011 session
PDF
Component level caching with react
PPTX
Angular js 1.3 presentation for fed nov 2014
PPTX
Angular js for beginners
PPTX
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
PPT
Angular js
PPTX
Angular js
PDF
Angular JS tutorial
PPTX
Angular introduction basic
PDF
PPTX
Ab testing work flow
PPTX
Angular js
PPTX
Single page application 03
Why angular js Framework
AngularJs (1.x) Presentation
AngularJS Best Practices
Angular JS - Introduction
Angular js
Angular js 1.0-fundamentals
Spring mvc
前后端mvc经验 - webrebuild 2011 session
Component level caching with react
Angular js 1.3 presentation for fed nov 2014
Angular js for beginners
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Angular js
Angular js
Angular JS tutorial
Angular introduction basic
Ab testing work flow
Angular js
Single page application 03
Ad

Similar to Angular js (20)

PPTX
AngularJs-training
PPTX
AngularJS.part1
PPTX
AngularJS
PPTX
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
PDF
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
PDF
Dependency Injection pattern in Angular
PPT
MEAN - Notes from the field (Full-Stack Development with Javascript)
PDF
Mini-Training: AngularJS
PPTX
Angular Js Get Started - Complete Course
PPTX
Intoduction to Angularjs
ODP
AngularJs Crash Course
PPTX
Basics of AngularJS
PPTX
Introduction to AngularJS
KEY
Single Page Web Apps with Backbone.js and Rails
KEY
Prateek dayal backbonerails-110528024926-phpapp02
PDF
AngularJS Basic Training
PDF
Introducing Rendr: Run your Backbone.js apps on the client and server
PPTX
Asp.Net Mvc
PPTX
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs-training
AngularJS.part1
AngularJS
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
Dependency Injection pattern in Angular
MEAN - Notes from the field (Full-Stack Development with Javascript)
Mini-Training: AngularJS
Angular Js Get Started - Complete Course
Intoduction to Angularjs
AngularJs Crash Course
Basics of AngularJS
Introduction to AngularJS
Single Page Web Apps with Backbone.js and Rails
Prateek dayal backbonerails-110528024926-phpapp02
AngularJS Basic Training
Introducing Rendr: Run your Backbone.js apps on the client and server
Asp.Net Mvc
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Ad

Recently uploaded (20)

PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
medical staffing services at VALiNTRY
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
AutoCAD Professional Crack 2025 With License Key
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
history of c programming in notes for students .pptx
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Cost to Outsource Software Development in 2025
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
assetexplorer- product-overview - presentation
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
medical staffing services at VALiNTRY
Autodesk AutoCAD Crack Free Download 2025
AutoCAD Professional Crack 2025 With License Key
Oracle Fusion HCM Cloud Demo for Beginners
Salesforce Agentforce AI Implementation.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
history of c programming in notes for students .pptx
Computer Software and OS of computer science of grade 11.pptx
Reimagine Home Health with the Power of Agentic AI​
Design an Analysis of Algorithms I-SECS-1021-03
Cost to Outsource Software Development in 2025
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
assetexplorer- product-overview - presentation
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
wealthsignaloriginal-com-DS-text-... (1).pdf
Nekopoi APK 2025 free lastest update
iTop VPN Free 5.6.0.5262 Crack latest version 2025

Angular js

  • 2. 1. Introduction to AngularJS 2. Controllers & Views 3. Services 4. Filters 5. Routing 6. Directives AGENDA
  • 3. A JavaScript framework for creating dynamic web applications INTRODUCTION TO ANGULARJS • Model The data • Controller The behavior Modifying / updating the models • View The interface How the data is presented to the user
  • 5. • Views are declarative The structure of the interface • Controllers do not need to directly manipulate the view Changes in the models / data are automatically reflected in the view Updates are managed by the frameworks CONTROLLERS AND VIEWS
  • 6. • Make use of special ng attributes (directives) on the HTML elements ng-app • Determines which part of the page will use AngularJS • If given a value it will load that application module ng-controller • Determines which Javascript Controller should be used for that part of the page ng-model • Determines what model the value of an input field will be bound to • Used for two-way binding CONTROLLERS AND VIEWS
  • 7. • More ng directives ngSwitch=<ANY ng-switch="expression"> <ANY ng-switch-when="matchValue1"></ANY> <ANY ng-switch-when="matchValue2"></ANY> <ANY ng-switch-default>...</ANY> </ANY> ng-if=“<model expression>” • Inserts HTML element if expression is true • Does not insert element in the DOM if it is false ng-repeat=“<variable> in <array>” • Repeats the HTML element for each value in the array • Also a key-value pair version for JSON objects “(<key>, <value>) in <JSON>” CONTROLLERS AND VIEWS
  • 8. <div ng-app="" ng-controller="personController"> First Name: <input type="text" ng-model="firstName"><br> Last Name: <input type="text" ng-model="lastName"><br> <br> Full Name: {{firstName + " " + lastName}} </div> <script> function personController($scope) { $scope.firstName = "John", $scope.lastName = "Doe" } </script> CONTROLLERS AND VIEWS
  • 9. $q A service that helps you run functions asynchronously, and use their return values (or exceptions) when they are done processing. $http.get('/api/v1/movies/avengers') .success(function(data, status, headers, config) { $scope.movieContent = data; }); // is the same as var promise = $http.get('/api/v1/movies/avengers'); promise.then( function(payload) { $scope.movieContent = payload.data; }) SERVICES
  • 10. module.factory(‘factory_id’, function() { return { functionname: function() { return “this is a function”; }, anotherfunction: function() { // make a request and get data from backend return data; } } }); FACTORY
  • 11. • Reusable operation using which you can modify the content that is shown on the page • Examples: uppercase a value, filter search results, etc. module.filter(“filter_name”, function(data) { // data is filtered or modified in a //specific manner and returned return data; } FILTERS
  • 12. • Use different views for different URL fragments • 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 ROUTING
  • 13. • URL parameters To access the parameters in the URL, use the $routeParams service The $routeParams object will have a field with the same name as the parameter Ex. • $routeParams.userId ROUTE PARAMS
  • 14. • URL parameters To access the parameters in the URL, use the $routeParams service The $routeParams object will have a field with the same name as the parameter Ex. • $routeParams.userId ROUTE PARAMS
  • 16. app.directive('ngSparkline', function() { return { restrict: 'A', require: '^ngCity', scope: { ngCity: '@' }, template: '<div class="sparkline"><h4>Weather for {{ngCity}}</h4></div>', controller: ['$scope', '$http', function($scope, $http) { $scope.getTemp = function(city) {} }], link: function(scope, iElement, iAttrs, ctrl) { scope.getTemp(iAttrs.ngCity); } } }); CUSTOM DIRECTIVES
  • 17. Raisers: $broadcast(parent scope to child scope) $emit(child scope to parent scope) Listeners $on EVENTS
  • 18. 'use strict'; angular.module('myAppControllers', []) .controller('FirstCtrl', function ($scope) { $scope.$broadcast('UPDATE_CHILD'); }) .controller('SecondCtrl', function ($scope) { $scope.$on('UPDATE_CHILD', function() { // do something useful here; }); }) EXAMPLE