SlideShare a Scribd company logo
-Santosh Kumar Kar
What is AngularJS
• JavaScript MVC framework for the Web
• pure JavaScript and HTML
• Unit Testable
• For Web and Mobile
• Less code
• Can integrate 3rd party libraries such as jQueryUI/BootStrap
MVC
• The model is the driving force of the application. This is generally the
data behind the application, usually fetched from the server. Any UI
with data that the user sees is derived from the model, or a subset of
the model.
• The view is the UI that the user sees and interacts with. It is dynamic,
and generated based on the current model of the application
• The controller is the business logic and presentation layer, which
performs actions such as fetching data, and makes decisions such as
how to present the model, which parts of it to display, etc.
First Application ng-app
Task – 1
• Write a Angular Application which prints the value of below
expressions:
• 5 *5 + 2*2
• 10/5*2-100
AngularJS Directives
• Markers on DOM elements (such as elements, attributes, css, and
more).
• Used to create custom HTML tags that serve as new, custom widgets.
• AngularJS has built-in directives (ngBind, ngModel...)
directive
ng-app
• first and most important directive
• Tells the section of HTML that AngularJS controls
• Need to put in any tag, preferable at <html> or <body>
• Anything outside of the tag would not be processed
directive
ng-model, ng-bind
directive
ng-model
• used with input fields, user to enter any data and get access to the
value in JavaScript.
• In ng-model="n1", AngularJS stores the value that the user types into
in a variable called "n1"
directive
ng-bind
• Binds with the Angular JS variable
• ng-bind in <span>
<span ng-bind="n1"
is similar to
{{n1}}
Modules
• Modules in AngularJS are similar to packages in java
• Container for the different parts of your app – controllers, services,
filters, directives, etc.
• Can define its own controllers, services, factories, and directives
which are accessed throughout the module.
• Can depend on other modules as dependencies and made available to
all the code defined in this module.
• angular.module(‘myApp', []);
Creating a module with no dependencies
• angular.module(‘myApp', ['myapp.ui', 'yourapp.diagram']);
Creating a module with 2 other dependent modules
• angular.module(‘myApp');
• looks an existing module to make it available to use, add, or modify in the
current file.
Module name we
define
Array of dependent
modules
Modules
Controller
• Fetch data from the server for UI
• Are regular JavaScript Objects.
• ng-controller directive defines the application controller.
Parent module
Child modules
Defined 2 Controllers
Using parent module
only
Task – 2
• Write an Angular Application which prints current date and time on
the screen
controllerAs
• Can be used in AngularJS 1.2 and later
• Allows to define the variables on the controller instance using the this
keyword instead of $scope
• Directly can be referred through the controller from the HTML
controllerAs
$scope.name = 'some value'
changed to
this.name = 'some value';
ng-controller="EmpController"
changed to
ng-controller="EmpController as emp"
{{ name }}
changed to
{{ emp.name }}
Angular js for Beginnners
directive
ng-repeat
• Similar to for each loop
• Allows to iterate over an array
• Allows to iterate over keys and values of an object
• Syntax: ng-repeat="eachVar in arrayVar"
Angular js for Beginnners
Calculator
Task – 3
• Write an Angular Application as
• Create a list which stores value of 5 students (id, name, marks) in a school
• In HTML, print the name and marks of all the students.
Calculator
Calculator
Forms
• ng-submit
• ng-disabled = "myForm.$invalid"
• required
form
JS
Task – 4
• Write an Angular Application
• Add few controls with different validation
• Add a submit button in the form.
• Submit button should be enabled only when all the validations are passed.
Error Handling
• Form validation
• required
• ng-required
• ng-minlength
• ng-maxlength
• ng-pattern
• type="email"
• type="number"
• type="date"
• type="url"
Dependency
Injection
• Any service known to
AngularJS can be injected into
any other service, directive,
or controller by stating it as a
dependency.
• AngularJS will automatically
create the entire chain before
injecting.
Controller vs Services
Services
• Service that is a reusable API or substitutable objects, which can be
shared across our applications.
• A service in AngularJS can be implemented as a
• factory
• service
• provider
Service types
• Build-in
• Custom
Common built-In Services
• $window
• $log
• $http
• $location
• $timeout
• $interval
Points to remember:
• AngularJS prefixes all the services that are provided by the AngularJS library with the $ sign.
• when you create your own services, do not prefix them with a $ sign. It will just end up confusing
you and your team at some point in time
Injecting service
Order of Injection
Creating Our Own Service
Creating your own service
Data with $http
• Similar to request to the server from AJAX applications (using
XMLHttpRequests)
• Makes request
• reads response
• checks the error codes
• processes the server response
• Traditional
• var xmlhttp = new XMLHttpRequest();
• xmlhttp.open("GET", "http://myserver/api", true);
Few test cases:
Input: 1, output: 1
Input:10, output: A
Input:15, output: F
Task – 5
• Write a Angular Application
• Add a service, this will take a decimal number as input and print the
hexadecimal value of that number.
$http with REST APIs
• GET
• HEAD
• POST
• DELETE
• PUT
• JSONP
GET request
Task – 6
• Write a Angular Application
• Which consumes restful web-service with GET, POST, DELETE
(you can write a web-service or see some examples with node.js to create demo restful web-
service)
Unit Testing
Filters
• Process data and format values to present
• Applied on expressions in HTML
• Applied directly on data in our controllers and services
• Examples:
• Format timestamp to readable date string
• Add currency symbol on a number
Angular js for Beginnners
Task – 7
• Write a Angular Application
• Use in-built filters and produce the below output
(you can write a web-service or see some examples with node.js to create demo restful web-
service)
Task – 8
• Write a Angular Application and use below built-in filters
• orderBy
• filter
• json
• limitTo
Custom Filters
Task – 8
• Write a custom filter which accepts a string value and prints every
alternate character in lower case preceding to a upper case character.
Test cases:
Input: AngularJS output:AnGuLaRjS
Filters in controllers
Routing with URL - myurl.html#/home
• You need Routing if
• we call hashbang URLs, not the standard URL
• You are developing a single page application
• You have multiple views for a single page (e.g. Home Page, About Us, Contact
Us etc.)
• For each request in a single page, you need to load one of the view as
presentation logic but you don’t want to refresh the page.
• You don’t need to load the whole page but only the contents of the view
• You need speed response by loading contents faster
Routing: how to code
• Import angular.js and angular-route.js
• Use dependancy model to ngRoute
var myvar = angular.module('org',['ngRoute']);
• Config the route provider
$routeProvider.when(url, {
template: string,
templateUrl: string,
controller: string, function or array,
controllerAs: string,
resolve: object<key, function>
});
Angular js for Beginnners
Request in routing : ‘#’ factor
• Request in a common URLs:
# in URLs
Task – 9
Make 3 Angular applications (3 views)
• Home.html
• About.html
• Contact.html
In index.html, you need to define 3 links for home, about and contact.
On clicking the links it needs to route to respective views without
reloading the page.
(Note: You may need to deploy as an application in a server to make it work.)
Things to do:
• I didn’t cover the unit testing parts in AngularJS along with mocking
up in this presentation for each of the components. I request you to
go through the steps for unit testing in internet. If I get time I would
add unit testing in a separate presentation. Thank you.
Angular js for Beginnners
Source Code at:
• https://github.com/santoshkar/Angular.git
Angular js for Beginnners

More Related Content

PPTX
Moving From AngularJS to Angular 2
PPTX
Angular js 1.0-fundamentals
PDF
JavaLand 2014 - Ankor.io Presentation
PDF
jQuery - Chapter 1 - Introduction
PDF
[2015/2016] Require JS and Handlebars JS
PPTX
Ankor Presentation @ JavaOne San Francisco September 2014
PPTX
Angular js
Moving From AngularJS to Angular 2
Angular js 1.0-fundamentals
JavaLand 2014 - Ankor.io Presentation
jQuery - Chapter 1 - Introduction
[2015/2016] Require JS and Handlebars JS
Ankor Presentation @ JavaOne San Francisco September 2014
Angular js

What's hot (20)

PPTX
Front end development with Angular JS
PDF
MVC 1.0 als alternative Webtechnologie
PPTX
Introduction to single page application with angular js
PDF
[2015/2016] JavaScript
PPTX
Comparing Angular and React JS for SPAs
PPTX
angularJs Workshop
PPTX
MVC Training Part 1
PPT
Mvc architecture
PDF
Angular - Chapter 3 - Components
PPTX
Angular Data Binding
PDF
Angular - Chapter 5 - Directives
ODP
Introduction to Knockout Js
PPTX
Object Oriented Programing in JavaScript
PPT
ASP .net MVC
PDF
PDF
jQuery and Rails: Best Friends Forever
PPTX
ASP .NET MVC
PDF
[2015/2016] Local data storage for web-based mobile apps
PPTX
ASP.NET MVC 5 - EF 6 - VS2015
PDF
Front end development with Angular JS
MVC 1.0 als alternative Webtechnologie
Introduction to single page application with angular js
[2015/2016] JavaScript
Comparing Angular and React JS for SPAs
angularJs Workshop
MVC Training Part 1
Mvc architecture
Angular - Chapter 3 - Components
Angular Data Binding
Angular - Chapter 5 - Directives
Introduction to Knockout Js
Object Oriented Programing in JavaScript
ASP .net MVC
jQuery and Rails: Best Friends Forever
ASP .NET MVC
[2015/2016] Local data storage for web-based mobile apps
ASP.NET MVC 5 - EF 6 - VS2015
Ad

Similar to Angular js for Beginnners (20)

PPTX
AngularJS One Day Workshop
PPTX
AngularJS Introduction (Talk given on Aug 5 2013)
PDF
AngularJS Basics and Best Practices - CC FE &UX
PPTX
Angular workshop - Full Development Guide
PPTX
Learning AngularJS - Complete coverage of AngularJS features and concepts
PPT
Angular js
PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
PPTX
Angular Presentation
PDF
AngularJS Workshop
PPTX
Intoduction to Angularjs
PPT
Introduction to AngularJS
PPTX
Training On Angular Js
PPT
Angularjs for kolkata drupal meetup
PPTX
AngularJS is awesome
PDF
AngularJS Beginner Day One
PPTX
Kalp Corporate Angular Js Tutorials
PPT
Angular js
PDF
One Weekend With AngularJS
PPTX
ME vs WEB - AngularJS Fundamentals
AngularJS One Day Workshop
AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Basics and Best Practices - CC FE &UX
Angular workshop - Full Development Guide
Learning AngularJS - Complete coverage of AngularJS features and concepts
Angular js
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
Angular Presentation
AngularJS Workshop
Intoduction to Angularjs
Introduction to AngularJS
Training On Angular Js
Angularjs for kolkata drupal meetup
AngularJS is awesome
AngularJS Beginner Day One
Kalp Corporate Angular Js Tutorials
Angular js
One Weekend With AngularJS
ME vs WEB - AngularJS Fundamentals
Ad

More from Santosh Kumar Kar (11)

PPTX
Smart home arduino
PPTX
Operating electrical devices with PIR sensor. No coding, No controller
PPTX
Temperature sensor with raspberry pi
PPTX
Pir motion sensor with raspberry pi
PPTX
Raspberry pi complete setup
PPTX
Introduction to spring boot
PPTX
Spring transaction part4
PPTX
Spring & hibernate
PPTX
Spring database - part2
PPTX
PPTX
Writing simple web services in java using eclipse editor
Smart home arduino
Operating electrical devices with PIR sensor. No coding, No controller
Temperature sensor with raspberry pi
Pir motion sensor with raspberry pi
Raspberry pi complete setup
Introduction to spring boot
Spring transaction part4
Spring & hibernate
Spring database - part2
Writing simple web services in java using eclipse editor

Recently uploaded (20)

PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
history of c programming in notes for students .pptx
PPTX
Transform Your Business with a Software ERP System
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
AI in Product Development-omnex systems
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
System and Network Administraation Chapter 3
PDF
System and Network Administration Chapter 2
PDF
Design an Analysis of Algorithms II-SECS-1021-03
top salesforce developer skills in 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
How to Choose the Right IT Partner for Your Business in Malaysia
history of c programming in notes for students .pptx
Transform Your Business with a Software ERP System
Operating system designcfffgfgggggggvggggggggg
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
wealthsignaloriginal-com-DS-text-... (1).pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
CHAPTER 2 - PM Management and IT Context
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
AI in Product Development-omnex systems
How to Migrate SBCGlobal Email to Yahoo Easily
Reimagine Home Health with the Power of Agentic AI​
How Creative Agencies Leverage Project Management Software.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
System and Network Administraation Chapter 3
System and Network Administration Chapter 2
Design an Analysis of Algorithms II-SECS-1021-03

Angular js for Beginnners

  • 2. What is AngularJS • JavaScript MVC framework for the Web • pure JavaScript and HTML • Unit Testable • For Web and Mobile • Less code • Can integrate 3rd party libraries such as jQueryUI/BootStrap
  • 3. MVC • The model is the driving force of the application. This is generally the data behind the application, usually fetched from the server. Any UI with data that the user sees is derived from the model, or a subset of the model. • The view is the UI that the user sees and interacts with. It is dynamic, and generated based on the current model of the application • The controller is the business logic and presentation layer, which performs actions such as fetching data, and makes decisions such as how to present the model, which parts of it to display, etc.
  • 5. Task – 1 • Write a Angular Application which prints the value of below expressions: • 5 *5 + 2*2 • 10/5*2-100
  • 6. AngularJS Directives • Markers on DOM elements (such as elements, attributes, css, and more). • Used to create custom HTML tags that serve as new, custom widgets. • AngularJS has built-in directives (ngBind, ngModel...)
  • 7. directive ng-app • first and most important directive • Tells the section of HTML that AngularJS controls • Need to put in any tag, preferable at <html> or <body> • Anything outside of the tag would not be processed
  • 9. directive ng-model • used with input fields, user to enter any data and get access to the value in JavaScript. • In ng-model="n1", AngularJS stores the value that the user types into in a variable called "n1"
  • 10. directive ng-bind • Binds with the Angular JS variable • ng-bind in <span> <span ng-bind="n1" is similar to {{n1}}
  • 11. Modules • Modules in AngularJS are similar to packages in java • Container for the different parts of your app – controllers, services, filters, directives, etc. • Can define its own controllers, services, factories, and directives which are accessed throughout the module. • Can depend on other modules as dependencies and made available to all the code defined in this module.
  • 12. • angular.module(‘myApp', []); Creating a module with no dependencies • angular.module(‘myApp', ['myapp.ui', 'yourapp.diagram']); Creating a module with 2 other dependent modules • angular.module(‘myApp'); • looks an existing module to make it available to use, add, or modify in the current file. Module name we define Array of dependent modules Modules
  • 13. Controller • Fetch data from the server for UI • Are regular JavaScript Objects. • ng-controller directive defines the application controller.
  • 14. Parent module Child modules Defined 2 Controllers Using parent module only
  • 15. Task – 2 • Write an Angular Application which prints current date and time on the screen
  • 16. controllerAs • Can be used in AngularJS 1.2 and later • Allows to define the variables on the controller instance using the this keyword instead of $scope • Directly can be referred through the controller from the HTML
  • 17. controllerAs $scope.name = 'some value' changed to this.name = 'some value'; ng-controller="EmpController" changed to ng-controller="EmpController as emp" {{ name }} changed to {{ emp.name }}
  • 19. directive ng-repeat • Similar to for each loop • Allows to iterate over an array • Allows to iterate over keys and values of an object • Syntax: ng-repeat="eachVar in arrayVar"
  • 22. Task – 3 • Write an Angular Application as • Create a list which stores value of 5 students (id, name, marks) in a school • In HTML, print the name and marks of all the students.
  • 25. Forms • ng-submit • ng-disabled = "myForm.$invalid" • required
  • 26. form
  • 27. JS
  • 28. Task – 4 • Write an Angular Application • Add few controls with different validation • Add a submit button in the form. • Submit button should be enabled only when all the validations are passed.
  • 29. Error Handling • Form validation • required • ng-required • ng-minlength • ng-maxlength • ng-pattern • type="email" • type="number" • type="date" • type="url"
  • 30. Dependency Injection • Any service known to AngularJS can be injected into any other service, directive, or controller by stating it as a dependency. • AngularJS will automatically create the entire chain before injecting.
  • 32. Services • Service that is a reusable API or substitutable objects, which can be shared across our applications. • A service in AngularJS can be implemented as a • factory • service • provider
  • 34. Common built-In Services • $window • $log • $http • $location • $timeout • $interval Points to remember: • AngularJS prefixes all the services that are provided by the AngularJS library with the $ sign. • when you create your own services, do not prefix them with a $ sign. It will just end up confusing you and your team at some point in time
  • 36. Creating Our Own Service
  • 37. Creating your own service
  • 38. Data with $http • Similar to request to the server from AJAX applications (using XMLHttpRequests) • Makes request • reads response • checks the error codes • processes the server response • Traditional • var xmlhttp = new XMLHttpRequest(); • xmlhttp.open("GET", "http://myserver/api", true);
  • 39. Few test cases: Input: 1, output: 1 Input:10, output: A Input:15, output: F Task – 5 • Write a Angular Application • Add a service, this will take a decimal number as input and print the hexadecimal value of that number.
  • 40. $http with REST APIs • GET • HEAD • POST • DELETE • PUT • JSONP
  • 42. Task – 6 • Write a Angular Application • Which consumes restful web-service with GET, POST, DELETE (you can write a web-service or see some examples with node.js to create demo restful web- service)
  • 44. Filters • Process data and format values to present • Applied on expressions in HTML • Applied directly on data in our controllers and services • Examples: • Format timestamp to readable date string • Add currency symbol on a number
  • 46. Task – 7 • Write a Angular Application • Use in-built filters and produce the below output (you can write a web-service or see some examples with node.js to create demo restful web- service)
  • 47. Task – 8 • Write a Angular Application and use below built-in filters • orderBy • filter • json • limitTo
  • 49. Task – 8 • Write a custom filter which accepts a string value and prints every alternate character in lower case preceding to a upper case character. Test cases: Input: AngularJS output:AnGuLaRjS
  • 51. Routing with URL - myurl.html#/home • You need Routing if • we call hashbang URLs, not the standard URL • You are developing a single page application • You have multiple views for a single page (e.g. Home Page, About Us, Contact Us etc.) • For each request in a single page, you need to load one of the view as presentation logic but you don’t want to refresh the page. • You don’t need to load the whole page but only the contents of the view • You need speed response by loading contents faster
  • 52. Routing: how to code • Import angular.js and angular-route.js • Use dependancy model to ngRoute var myvar = angular.module('org',['ngRoute']); • Config the route provider $routeProvider.when(url, { template: string, templateUrl: string, controller: string, function or array, controllerAs: string, resolve: object<key, function> });
  • 54. Request in routing : ‘#’ factor • Request in a common URLs: # in URLs
  • 55. Task – 9 Make 3 Angular applications (3 views) • Home.html • About.html • Contact.html In index.html, you need to define 3 links for home, about and contact. On clicking the links it needs to route to respective views without reloading the page. (Note: You may need to deploy as an application in a server to make it work.)
  • 56. Things to do: • I didn’t cover the unit testing parts in AngularJS along with mocking up in this presentation for each of the components. I request you to go through the steps for unit testing in internet. If I get time I would add unit testing in a separate presentation. Thank you.
  • 58. Source Code at: • https://github.com/santoshkar/Angular.git