SlideShare a Scribd company logo
A Different Thought
AngularJS Part-3
Agenda
Agenda
1. Core Service
Agenda
1. Core Service
a. $location
Agenda
1. Core Service
a. $location
b. $http
Agenda
1. Core Service
a. $location
b. $http
2. Custom Service
Agenda
1. Core Service
a. $location
b. $http
2. Custom Service
3. Custom Directive
Agenda
1. Core Service
a. $location
b. $http
2. Custom Service
3. Custom Directive
4. Integrate TODO app with REST API
About Me
Amit Thakkar
Tech Blogger @ CodeChutney.in
JavaScript Lover
Working on MEAN Stack
Twitter: @amit_thakkar01
LinkedIn: linkedin.com/in/amitthakkar01
Facebook: facebook.com/amit.thakkar01
Core Services - $location
(function (ng) {
var todoApp = ng.module("todo", []);
todoApp.controller("TODOController", ["$location", function ($location) {
console.log($location.$$absUrl == "http://localhost:3000/TODO.html"); // true
console.log($location.$$host == "localhost"); // true
console.log($location.$$port == 3000); // true
}]);
})(angular);
Core Services - $location
(function (ng) {
var todoApp = ng.module("todo", []);
todoApp.controller("TODOController", ["$location", function ($location) {
console.log($location.$$absUrl == "http://localhost:3000/TODO.html"); // true
console.log($location.$$host == "localhost"); // true
console.log($location.$$port == 3000); // true
}]);
})(angular);
Core Services - $location
(function (ng) {
var todoApp = ng.module("todo", []);
todoApp.controller("TODOController", ["$location", function ($location) {
console.log($location.$$absUrl == "http://localhost:3000/TODO.html"); // true
console.log($location.$$host == "localhost"); // true
console.log($location.$$port == 3000); // true
}]);
})(angular);
You can checkout Demo form:
https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
Core Services - $http
(function (ng) {
var todoApp = ng.module("todo", []);
todoApp.controller("TODOController", ["$http", function ($http) {
$http.get("todo")
.success(function (todo) {
todoController.tasks = todo;
})
.error(function (error) {
// Handle error here.
console.log(error);
});
}]);
})(angular);
Core Services - $http
(function (ng) {
var todoApp = ng.module("todo", []);
todoApp.controller("TODOController", ["$http", function ($http) {
$http.get("todo")
.success(function (todo) {
todoController.tasks = todo;
})
.error(function (error) {
// Handle error here.
console.log(error);
});
}]);
})(angular);
Core Services - $http
(function (ng) {
var todoApp = ng.module("todo", []);
todoApp.controller("TODOController", ["$http", function ($http) {
$http.get("todo")
.success(function (todo) {
todoController.tasks = todo;
})
.error(function (error) {
// Handle error here.
console.log(error);
});
}]);
})(angular);
You can checkout Demo form:
https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
Custom Services - TodoService
(function (ng) {
var todoApp = ng.module("todo");
todoApp.service("TODOService", ["$http", function ($http) {
var API_URL = "todo";
var todoService = this;
todoService.getTODOList = function () {
return $http.get(API_URL);
};
}]);
})(angular);
Custom Services - TodoService
(function (ng) {
var todoApp = ng.module("todo");
todoApp.service("TODOService", ["$http", function ($http) {
var API_URL = "todo";
var todoService = this;
todoService.getTODOList = function () {
return $http.get(API_URL);
};
}]);
})(angular);
Custom Services - TodoService
(function (ng) {
var todoApp = ng.module("todo");
todoApp.service("TODOService", ["$http", function ($http) {
var API_URL = "todo";
var todoService = this;
todoService.getTODOList = function () {
return $http.get(API_URL);
};
}]);
})(angular);
You can checkout Demo form:
https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
var todoApp = ng.module("todo");
todoApp.directive("keyEnter", function () {
return {
link: function (scope, element, attrs) {
element.bind("keyup", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.keyEnter);
});
event.preventDefault();
}
});
}
};
});
Custom Directive - keyEnter
var todoApp = ng.module("todo");
todoApp.directive("keyEnter", function () {
return {
link: function (scope, element, attrs) {
element.bind("keyup", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.keyEnter);
});
event.preventDefault();
}
});
}
};
});
Custom Directive - keyEnter
var todoApp = ng.module("todo");
todoApp.directive("keyEnter", function () {
return {
link: function (scope, element, attrs) {
element.bind("keyup", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.keyEnter);
});
event.preventDefault();
}
});
}
};
});
Custom Directive - keyEnter
You can checkout Demo form:
https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
TODO App with RESP API
You can checkout Demo form:
https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
Questions??
References:
Service in AngularJS

More Related Content

PPT
Angular data binding by Soft Solutions4U
KEY
Modern Architecture
PDF
Emberjs building-ambitious-web-applications
ODP
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
PPTX
1. CodeIgniter 1
PDF
Documentation vs test about cucumber but not only for vegetarians
PPTX
SignalR: Above & Beyond Chat
PPTX
SFNode 01-2018 - Aquarium control
Angular data binding by Soft Solutions4U
Modern Architecture
Emberjs building-ambitious-web-applications
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
1. CodeIgniter 1
Documentation vs test about cucumber but not only for vegetarians
SignalR: Above & Beyond Chat
SFNode 01-2018 - Aquarium control

What's hot (19)

PDF
Aiy project, el día que le hablé a una caja
PDF
Ember.js for Big Profit
PDF
Activity streams lightning talk, DjangoCon 2011 Day 3
PDF
1時間で作るマッシュアップサービス(関西版)
PDF
Symfony bundle fo asynchronous job processing
PPTX
Dart and AngularDart
PDF
Build REST API clients for AngularJS
PDF
Gigigo Rails Workshop
PDF
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...
PDF
Angular js routing options
PPTX
Angular 2.0 Routing and Navigation
PPTX
Building a dashboard using AngularJS
PPTX
Dive into AngularJS Routing
PDF
CFUGbe talk about Angular JS
PDF
Intro to the Intersection Observer API - Tara Ojo
PPTX
UI-Router
PPTX
Dexetra Labs - Building Apps that can get featured
PDF
Neoito — React 101
PDF
What's new in iOS9
Aiy project, el día que le hablé a una caja
Ember.js for Big Profit
Activity streams lightning talk, DjangoCon 2011 Day 3
1時間で作るマッシュアップサービス(関西版)
Symfony bundle fo asynchronous job processing
Dart and AngularDart
Build REST API clients for AngularJS
Gigigo Rails Workshop
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...
Angular js routing options
Angular 2.0 Routing and Navigation
Building a dashboard using AngularJS
Dive into AngularJS Routing
CFUGbe talk about Angular JS
Intro to the Intersection Observer API - Tara Ojo
UI-Router
Dexetra Labs - Building Apps that can get featured
Neoito — React 101
What's new in iOS9
Ad

Viewers also liked (16)

PPTX
A different thought angular js part-2
PPT
MongoDB - An Agile NoSQL Database
PDF
Design a landing page
PDF
Angular js meetup
PPTX
Design pattern in an expressive language java script
PDF
Angular.js Fundamentals
PPTX
A different thought AngularJS
PDF
AngularJS Basics
PDF
How AngularJS Embraced Traditional Design Patterns
PDF
Design patterns in java script, jquery, angularjs
PPTX
Practical AngularJS
PPTX
076 Modular Construction
PPTX
Benefits of developing single page web applications using angular js
PPTX
Building modular enterprise scale angular js applications
PPTX
Angular js for enteprise application
PDF
Oldcastle Precast Spokane - Urban Modular Construction - The Grand Hotel
A different thought angular js part-2
MongoDB - An Agile NoSQL Database
Design a landing page
Angular js meetup
Design pattern in an expressive language java script
Angular.js Fundamentals
A different thought AngularJS
AngularJS Basics
How AngularJS Embraced Traditional Design Patterns
Design patterns in java script, jquery, angularjs
Practical AngularJS
076 Modular Construction
Benefits of developing single page web applications using angular js
Building modular enterprise scale angular js applications
Angular js for enteprise application
Oldcastle Precast Spokane - Urban Modular Construction - The Grand Hotel
Ad

Similar to A different thought angular js part-3 (20)

PPTX
Angular Workshop_Sarajevo2
PPTX
The future of web development write once, run everywhere with angular.js and ...
PDF
The future of web development write once, run everywhere with angular js an...
PPTX
AngularJs-training
PDF
Angular js 24 april 2013 amsterdamjs
PPTX
AngularJS - a radically different way of building Single Page Apps
PPTX
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
PDF
Angularjs & REST
PPTX
AngularJS with TypeScript and Windows Azure Mobile Services
PPTX
Angular Presentation
PDF
A single language for backend and frontend from AngularJS to cloud with Clau...
PDF
A single language for backend and frontend from AngularJS to cloud with Clau...
PDF
Angular2 with TypeScript
PPTX
AngularJS One Day Workshop
PPTX
Angular Js Basics
PDF
A gently introduction to AngularJS
PDF
Angular Promises and Advanced Routing
PDF
REST in AngularJS
PPT
Angular In Depth
PPTX
Angular js for Beginnners
Angular Workshop_Sarajevo2
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular js an...
AngularJs-training
Angular js 24 april 2013 amsterdamjs
AngularJS - a radically different way of building Single Page Apps
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angularjs & REST
AngularJS with TypeScript and Windows Azure Mobile Services
Angular Presentation
A single language for backend and frontend from AngularJS to cloud with Clau...
A single language for backend and frontend from AngularJS to cloud with Clau...
Angular2 with TypeScript
AngularJS One Day Workshop
Angular Js Basics
A gently introduction to AngularJS
Angular Promises and Advanced Routing
REST in AngularJS
Angular In Depth
Angular js for Beginnners

More from Amit Thakkar (7)

PDF
Packer
PDF
Packer
PPTX
AWS Cloud Formation
PPTX
Introduction to node js
PPTX
Java script at backend nodejs
PPTX
Building user interface with react
PPTX
Get expertise with mongo db
Packer
Packer
AWS Cloud Formation
Introduction to node js
Java script at backend nodejs
Building user interface with react
Get expertise with mongo db

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Modernizing your data center with Dell and AMD
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Sensors and Actuators in IoT Systems using pdf
PPTX
Cloud computing and distributed systems.
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Transforming Manufacturing operations through Intelligent Integrations
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Understanding_Digital_Forensics_Presentation.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding
Modernizing your data center with Dell and AMD
Advanced methodologies resolving dimensionality complications for autism neur...
Sensors and Actuators in IoT Systems using pdf
Cloud computing and distributed systems.
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
The AUB Centre for AI in Media Proposal.docx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Transforming Manufacturing operations through Intelligent Integrations
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Monthly Chronicles - July 2025
Reach Out and Touch Someone: Haptics and Empathic Computing

A different thought angular js part-3

  • 5. Agenda 1. Core Service a. $location b. $http
  • 6. Agenda 1. Core Service a. $location b. $http 2. Custom Service
  • 7. Agenda 1. Core Service a. $location b. $http 2. Custom Service 3. Custom Directive
  • 8. Agenda 1. Core Service a. $location b. $http 2. Custom Service 3. Custom Directive 4. Integrate TODO app with REST API
  • 9. About Me Amit Thakkar Tech Blogger @ CodeChutney.in JavaScript Lover Working on MEAN Stack Twitter: @amit_thakkar01 LinkedIn: linkedin.com/in/amitthakkar01 Facebook: facebook.com/amit.thakkar01
  • 10. Core Services - $location (function (ng) { var todoApp = ng.module("todo", []); todoApp.controller("TODOController", ["$location", function ($location) { console.log($location.$$absUrl == "http://localhost:3000/TODO.html"); // true console.log($location.$$host == "localhost"); // true console.log($location.$$port == 3000); // true }]); })(angular);
  • 11. Core Services - $location (function (ng) { var todoApp = ng.module("todo", []); todoApp.controller("TODOController", ["$location", function ($location) { console.log($location.$$absUrl == "http://localhost:3000/TODO.html"); // true console.log($location.$$host == "localhost"); // true console.log($location.$$port == 3000); // true }]); })(angular);
  • 12. Core Services - $location (function (ng) { var todoApp = ng.module("todo", []); todoApp.controller("TODOController", ["$location", function ($location) { console.log($location.$$absUrl == "http://localhost:3000/TODO.html"); // true console.log($location.$$host == "localhost"); // true console.log($location.$$port == 3000); // true }]); })(angular);
  • 13. You can checkout Demo form: https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
  • 14. Core Services - $http (function (ng) { var todoApp = ng.module("todo", []); todoApp.controller("TODOController", ["$http", function ($http) { $http.get("todo") .success(function (todo) { todoController.tasks = todo; }) .error(function (error) { // Handle error here. console.log(error); }); }]); })(angular);
  • 15. Core Services - $http (function (ng) { var todoApp = ng.module("todo", []); todoApp.controller("TODOController", ["$http", function ($http) { $http.get("todo") .success(function (todo) { todoController.tasks = todo; }) .error(function (error) { // Handle error here. console.log(error); }); }]); })(angular);
  • 16. Core Services - $http (function (ng) { var todoApp = ng.module("todo", []); todoApp.controller("TODOController", ["$http", function ($http) { $http.get("todo") .success(function (todo) { todoController.tasks = todo; }) .error(function (error) { // Handle error here. console.log(error); }); }]); })(angular);
  • 17. You can checkout Demo form: https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
  • 18. Custom Services - TodoService (function (ng) { var todoApp = ng.module("todo"); todoApp.service("TODOService", ["$http", function ($http) { var API_URL = "todo"; var todoService = this; todoService.getTODOList = function () { return $http.get(API_URL); }; }]); })(angular);
  • 19. Custom Services - TodoService (function (ng) { var todoApp = ng.module("todo"); todoApp.service("TODOService", ["$http", function ($http) { var API_URL = "todo"; var todoService = this; todoService.getTODOList = function () { return $http.get(API_URL); }; }]); })(angular);
  • 20. Custom Services - TodoService (function (ng) { var todoApp = ng.module("todo"); todoApp.service("TODOService", ["$http", function ($http) { var API_URL = "todo"; var todoService = this; todoService.getTODOList = function () { return $http.get(API_URL); }; }]); })(angular);
  • 21. You can checkout Demo form: https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
  • 22. var todoApp = ng.module("todo"); todoApp.directive("keyEnter", function () { return { link: function (scope, element, attrs) { element.bind("keyup", function (event) { if (event.which === 13) { scope.$apply(function () { scope.$eval(attrs.keyEnter); }); event.preventDefault(); } }); } }; }); Custom Directive - keyEnter
  • 23. var todoApp = ng.module("todo"); todoApp.directive("keyEnter", function () { return { link: function (scope, element, attrs) { element.bind("keyup", function (event) { if (event.which === 13) { scope.$apply(function () { scope.$eval(attrs.keyEnter); }); event.preventDefault(); } }); } }; }); Custom Directive - keyEnter
  • 24. var todoApp = ng.module("todo"); todoApp.directive("keyEnter", function () { return { link: function (scope, element, attrs) { element.bind("keyup", function (event) { if (event.which === 13) { scope.$apply(function () { scope.$eval(attrs.keyEnter); }); event.preventDefault(); } }); } }; }); Custom Directive - keyEnter
  • 25. You can checkout Demo form: https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
  • 26. TODO App with RESP API You can checkout Demo form: https://github.com/AmitThakkar/A-Different-Thought-AngualarJS