SlideShare a Scribd company logo
ANGULARJS By Gaurav Agrawal
HTML enhanced for web apps!
What is ANGULARJS?
• AngularJS is an open source javascript based
web application framework. (Current stable
version 1.4.8 )
• It’s not a JavaScript library (As they say) but a
framework. There are no functions which we
can directly call and use.
• Focus more on HTML side of web apps.
• For MVC/MVVM design pattern
Key Features
• AngularJS is a powerful JavaScript based development framework to create RICH Internet Application(RIA).
• It provides developers options to write client side application (using JavaScript) in a clean MVC(Model View
Controller) way.
• Applications written in AngularJS is cross-browser compliant. It automatically handles JavaScript code
suitable for each browser.
• It is open source, completely free, and used by thousands of developers around the world. It is licensed
under the Apache License version 2.0.
• Overall, AngularJS is a framework to build large scale and high performance web application while keeping
them as easy-to-maintain.
Why ANGULARJS?
• It defines numerous ways to organize web application at client side.
• It Enhances HTML by attaching directives, custom tags, attributes, expressions, templates within
HTML.
• Encourage MVC/MVVM design pattern
• Code Reuse
• Good for Single Page Apps (SPA) - Single-Page Applications (SPAs) are Web apps that load
a singleHTML page and dynamically update that page as the user interacts with the app. SPAs
use AJAX and HTML5 to create fluid and responsive Web apps, without constant page reloads.
(eg: Gmail)
Core Features of ANGULARJS
• Easy Data Binding : Two way Data
Binding
• Reusable Components
• MVC/MVVM Design Pattern
• End to end Integration Testing / Unit
Testing
• Cross-browser compliant
• Services
• Expressions
• Filters
• Directives
• Form Validation
• Modular
2 Way Data Binding
Data binding is an AngularJS feature
that automatically synchronizes your
model data with your HTML.
Whenever the HTML is changed the
model gets updated and wherever
the model gets updated it is reflected
in HTML.
Identify MVC in Angular Js
Execution
ā€œWelcome AngularJS to the world of Tutorialspoint!ā€
When the page is loaded in the browser, following things happen āˆ’
• HTML document is loaded into the browser, and evaluated by the browser. AngularJS JavaScript file is loaded, the
angular global object is created. Next, JavaScript which registers controller functions is executed.
• Next AngularJS scans through the HTML to look for AngularJS apps and views. Once view is located, it connects
that view to the corresponding controller function.
• Next, AngularJS executes the controller functions. It then renders the views with data from the model populated
by the controller. The page is now ready.
Steps to create Angular App
Step 1 āˆ’ Load framework
Being a pure JavaScript framework, It can be added using <Script> tag.
<script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"> </script>
Step 2 āˆ’ Define AngularJS Application using ng-app directive
<div ng-app = ""> ... </div>
Step 3 āˆ’ Define a model name using ng-model directive
<p>Enter your Name: <input type = "text" ng-model = "name"></p>
Step 4 āˆ’ Bind the value of above model defined using ng-bind directive.
<p>Hello <span ng-bind = "name"></span>!</p>
Directive (teaches HTML new tricks.)
The directives can be placed in element names, attributes, class names, as well as
comments. Directives are a way to teach HTML new tricks.
A directive is just a function which executes when the compiler encounters it in the DOM.
<input ng-model='name'>
Custom Defined Directives
<span draggable>Drag ME</span>
How AngularJS integrates with HTML
ng-app directive indicates the start of AngularJS application.
ng-model(two way) The ngModel directive binds an input, select, textarea (or custom form
control) to a property on the scope. ($scope --> view and view --> $scope)
ng-bind(one way) The ngBind attribute tells Angular to replace the text content of the
specified HTML element(div or p or span) with the value of a given expression, and to update
the text content when the value of that expression changes. ($scope --> view)
Closing</div> tag indicates the end of AngularJS application.
Expression
AngularJS will "output" data exactly where the expression is written.
{{ expression }}
<body>
1+2={{1+2}}
</body>
Alternative is to use ā€˜ng-bind’ directive.
Module (the modular approach)
AngularJS supports modular approach. Modules are used to separate logics say services,
controllers, etc. and keep the code clean. We define modules in separate js files and name them
as per the module.js file. eg:
1)mainApp.js
var mainApp = angular.module("mainApp", []);
var mainApp2 = angular.module("mainApp2", []);
2)Controller.js
mainApp.controller("studentController", function($scope) {………………}
Here we've declared a controller studentController module using mainApp.controller function.
Use Module
<div ng-app = "mainAppā€œ>
<div ng-controller = "studentController"></div>
<div ng-controller = ā€œotherController"></div>
</div>
Here we've used application module using ng-app directive and controller using ng-
controller directive. We've imported mainApp.js and studentController.js in the main html
page.
Services (reusable singleton object )
In AngularJS, services are reusable singleton objects that are used to organize and share code across
your app. They can be injected into controllers, filters and directives. AngularJS provides you three ways
to create services: service, factory and provider.
Only one Instance of service is available within the app. For example, after a successful login, you'll
need to store the login status where the status can be retrieved in all other components. In this
scenario, you can store the status in a service and then, whenever you need to read the value, you can
just inject it into your controller/service and check it.
AngularJS provides many inbuilt services for example, $http, $route, $window, $location etc. Each
service is responsible for a specific task for example, $http is used to make ajax call to get the server
data. $route is used to define the routing information and so on. Inbuilt services are always prefixed
with $ symbol.
Why we need Service ?
ā€œIf You wish to share business logic between controllersā€
Two of the five SOLID principles of object oriented design are directly related to Services: the Single
Responsibility Principle (SRP) and the Dependency Inversion Principle (DIP).
The single responsibility principle teaches that every object should have a single responsibility. If we
use the example of a controller, it’s responsibility is essentially to wire up the scope (which holds your
models) to your view; it is essentially the bridge between your models and your views. If your
controller is also responsible for making ajax calls to fetch and update data, this is a violation of the
SRP principle. Logic like that (and other business logic) should instead be abstracted out into a
separate service, then injected into the objects that need to use it.
Factories vs. Services
First, right off the bat I’ll say they’re pretty much equivalent. Why do we have them both,
then? They both allow us to create an object that can then be used anywhere in our app.
Most important is to realize that both are singletons in your app.
Essentially, factories are functions that return the object, while services are constructor
functions of the object which are instantiated with the new keyword.
http://blog.thoughtram.io/angular/2015/07/07/service-vs-factory-once-and-for-all.html
http://www.codelord.net/2015/04/28/angularjs-whats-the-difference-between-factory-and-service/
Scope (the owner of application variables and functions)
$scope: It is an object that contains all the data to which HTML is bound. They act as the glue
for your javascript code (controllers) and the view (HTML). Everything that is attached to
the $scope, it is automatically watched by AngularJS and updated.
<script>
var mainApp = angular.module(ā€œmyApp", []);
mainApp.controller("shapeController", function($scope) {
$scope.message = "In shape controller";
$scope.type = "Shape";
});
</script>
Controllers(a JavaScript Object)
Controllers is a JavaScript Object, created by a standard JavaScript object constructor.
AngularJS application mainly relies on controllers to control the flow of data in the
application. A controller is defined using ng-controller directive. Each controller accepts
$scope as a parameter which refers to the application/module that controller is to control.
<div ng-app = "" ng-controller = "studentController"> ... </div>
Here we've declared a controller studentController using ng-controller directive.
Filters
Selects a subset of items from array and returns it as a new array.
Angular filters format data for display to the user.
{{ expression [| filter_name[:parameter_value] ... ] }}
{{ uppercase_expression | uppercase }}
{{ expression | filter1 | filter2 }}
Can create custom filters
Advantages of AngularJS
• It provides the capability to create Single Page Application in a very clean and
maintainable way.
• It provides data binding capability to HTML. Thus, it gives user a rich and responsive
experience.
• AngularJS code is unit testable.
• AngularJS uses dependency injection and make use of separation of concerns.
• AngularJS provides reusable components.
• With AngularJS, the developers can achieve more functionality with short code.
• In AngularJS, views are pure html pages, and controllers written in JavaScript do the
business processing.
Disadvantages of AngularJS
Though AngularJS comes with a lot of merits, here are some points of concern:
1. Not secure : Being JavaScript only framework, application written in AngularJS are not
safe. Server side authentication and authorization is must to keep an application secure.
2. Not degradable: If the user of your application disables JavaScript, then nothing would
be visible, except the basic page.
Summary
If you compare jQuery and Angular, the former is a library and the latter is a framework. You can plug
the library in your project and either use it fully, partially or not use it all. It’s like a plugin, a supplement
to your JS project. With a framework – you have to play by its rules, either use it fully or don’t use it all.
Angular.js is a MVC framework, it has model, view and controller which is one of the most popular
software development architectures today. When developing with Angular, you have to start from the
ground up with your architecture in mind.
Angular doesn’t replace jQuery, it doesn’t compete with jQuery, they both can be used in the same
application. jQuery for DOM manipulation, Angular – for structure. In fact there is nothing better to do
DOM manipulation than jQuery.
Resources
Documentation
• AngularJS Developer Guide
• AngularJS API
• AngularJS Tutorial
Videos
• AngularJS Fundamentals In 60-ish Minutes
• Introduction to Angular JS
• AngularJS end-to-end web app tutorial Part I
Thank You
Any Question ?

More Related Content

PPTX
Angularjs PPT
Amit Baghel
Ā 
PPTX
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
Ā 
PPTX
AngularJs (1.x) Presentation
Raghubir Singh
Ā 
PDF
AngularJS
Hiten Pratap Singh
Ā 
PDF
Angular js
Knoldus Inc.
Ā 
PDF
AngularJS in practice
Eugene Fidelin
Ā 
PPTX
The Basics Angular JS
OrisysIndia
Ā 
PPT
introduction to Angularjs basics
Ravindra K
Ā 
Angularjs PPT
Amit Baghel
Ā 
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
Ā 
AngularJs (1.x) Presentation
Raghubir Singh
Ā 
AngularJS
Hiten Pratap Singh
Ā 
Angular js
Knoldus Inc.
Ā 
AngularJS in practice
Eugene Fidelin
Ā 
The Basics Angular JS
OrisysIndia
Ā 
introduction to Angularjs basics
Ravindra K
Ā 

What's hot (20)

PDF
One Weekend With AngularJS
Yashobanta Bai
Ā 
PPSX
Angular js
Arun Somu Panneerselvam
Ā 
PDF
Angular 4 for Java Developers
Yakov Fain
Ā 
PPTX
Angular js presentation at Datacom
David Xi Peng Yang
Ā 
PPTX
Introduction to single page application with angular js
Mindfire Solutions
Ā 
PDF
AngularJS - Services
Nir Kaufman
Ā 
PDF
Angular from Scratch
Christian Lilley
Ā 
PPTX
Angular tutorial
Rohit Gupta
Ā 
PPTX
Front end development with Angular JS
Bipin
Ā 
PPTX
Angular interview questions
Goa App
Ā 
PDF
AngularJS Best Practices
Betclic Everest Group Tech Team
Ā 
PPTX
Introduction to Angular JS
Santhosh Kumar Srinivasan
Ā 
PDF
Integrating consumers IoT devices into Business Workflow
Yakov Fain
Ā 
PPTX
Getting Started with Angular JS
Akshay Mathur
Ā 
PPTX
AngularJs Workshop SDP December 28th 2014
Ran Wahle
Ā 
PDF
Introduction of angular js
Tamer Solieman
Ā 
PDF
AngularJS 101 - Everything you need to know to get started
StƩphane BƩgaudeau
Ā 
PDF
Introduction to Unit Tests and TDD
Betclic Everest Group Tech Team
Ā 
PPTX
angularJs Workshop
Ran Wahle
Ā 
One Weekend With AngularJS
Yashobanta Bai
Ā 
Angular 4 for Java Developers
Yakov Fain
Ā 
Angular js presentation at Datacom
David Xi Peng Yang
Ā 
Introduction to single page application with angular js
Mindfire Solutions
Ā 
AngularJS - Services
Nir Kaufman
Ā 
Angular from Scratch
Christian Lilley
Ā 
Angular tutorial
Rohit Gupta
Ā 
Front end development with Angular JS
Bipin
Ā 
Angular interview questions
Goa App
Ā 
AngularJS Best Practices
Betclic Everest Group Tech Team
Ā 
Introduction to Angular JS
Santhosh Kumar Srinivasan
Ā 
Integrating consumers IoT devices into Business Workflow
Yakov Fain
Ā 
Getting Started with Angular JS
Akshay Mathur
Ā 
AngularJs Workshop SDP December 28th 2014
Ran Wahle
Ā 
Introduction of angular js
Tamer Solieman
Ā 
AngularJS 101 - Everything you need to know to get started
StƩphane BƩgaudeau
Ā 
Introduction to Unit Tests and TDD
Betclic Everest Group Tech Team
Ā 
angularJs Workshop
Ran Wahle
Ā 
Ad

Viewers also liked (20)

PDF
Geosocial Applications and the Enterprise
CSRA, Inc.
Ā 
PPT
Khartoum Management Forum
Ridewise
Ā 
DOCX
Kombinatorika i vjerojatnost
Privatna jezično-informatička gimnazija "Svijet"
Ā 
PPTX
The truth about hybrids
James Zurbo
Ā 
PPT
Hallo,
Maria Chatzigiossi
Ā 
PPS
Parcs du Canada
Balcon60
Ā 
PPTX
Presentaciones quimuica 1
JUANHERNANDEZDIAZ
Ā 
PPTX
งานคอด
yahyah588
Ā 
PDF
Social Business for Associations: Building B2B Business with Relationship-Foc...
CSRA, Inc.
Ā 
PPTX
2012 AP Stats Project (3)
rickykyip
Ā 
PPTX
Como os Anabolizantes agem no Corpo Humano
JosƩ Levy
Ā 
PDF
Artikel ilmiah desain pekerjaan
magdalena praharani
Ā 
PPTX
Uso de la coma, clasificación y acentuación de las palabras
gabyllerena3
Ā 
PPTX
EVOLUCION LITERATURA
Ssara Palomino
Ā 
PDF
Farmacos aparato digestivo abril 2013 uft sesion2
Alejandro Letelier
Ā 
PDF
Farmacos antibacterianos abril 2013 uft rev
Alejandro Letelier
Ā 
PPS
Cologne allemagne
Balcon60
Ā 
PDF
my resume
asifmech91
Ā 
PDF
РИФ 2016, Боты в ŠæŠ¾Š¼Š¾Ń‰ŃŒ контент-Š¼ŠµŠ½ŠµŠ“Š¶ŠµŃ€Ńƒ или как Š°Š²Ń‚Š¾Š¼Š°Ń‚ŠøŠ·ŠøŃ€Š¾Š²Š°Ń‚ŃŒ Š·Š°Š³Ń€ŃƒŠ·ŠŗŃƒ Šŗ...
Тарасов ŠšŠ¾Š½ŃŃ‚антин
Ā 
PDF
Juniores e primÔrios 2016 lição biblica infantil
Marilene Rangel Rangel
Ā 
Geosocial Applications and the Enterprise
CSRA, Inc.
Ā 
Khartoum Management Forum
Ridewise
Ā 
The truth about hybrids
James Zurbo
Ā 
Parcs du Canada
Balcon60
Ā 
Presentaciones quimuica 1
JUANHERNANDEZDIAZ
Ā 
งานคอด
yahyah588
Ā 
Social Business for Associations: Building B2B Business with Relationship-Foc...
CSRA, Inc.
Ā 
2012 AP Stats Project (3)
rickykyip
Ā 
Como os Anabolizantes agem no Corpo Humano
JosƩ Levy
Ā 
Artikel ilmiah desain pekerjaan
magdalena praharani
Ā 
Uso de la coma, clasificación y acentuación de las palabras
gabyllerena3
Ā 
EVOLUCION LITERATURA
Ssara Palomino
Ā 
Farmacos aparato digestivo abril 2013 uft sesion2
Alejandro Letelier
Ā 
Farmacos antibacterianos abril 2013 uft rev
Alejandro Letelier
Ā 
Cologne allemagne
Balcon60
Ā 
my resume
asifmech91
Ā 
РИФ 2016, Боты в ŠæŠ¾Š¼Š¾Ń‰ŃŒ контент-Š¼ŠµŠ½ŠµŠ“Š¶ŠµŃ€Ńƒ или как Š°Š²Ń‚Š¾Š¼Š°Ń‚ŠøŠ·ŠøŃ€Š¾Š²Š°Ń‚ŃŒ Š·Š°Š³Ń€ŃƒŠ·ŠŗŃƒ Šŗ...
Тарасов ŠšŠ¾Š½ŃŃ‚антин
Ā 
Juniores e primÔrios 2016 lição biblica infantil
Marilene Rangel Rangel
Ā 
Ad

Similar to Intoduction to Angularjs (20)

PDF
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
Ā 
PDF
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
Ā 
PPTX
Kalp Corporate Angular Js Tutorials
Kalp Corporate
Ā 
PDF
Dive into AngularJS and directives
Tricode (part of Dept)
Ā 
PPTX
AngularJS is awesome
Eusebiu Schipor
Ā 
PPTX
Angularjs basic part01
Mohd Abdul Baquee
Ā 
PPTX
Angular js
ParmarAnisha
Ā 
PPTX
ANGULARJS introduction components services and directives
SanthoshB77
Ā 
PPTX
Angular workshop - Full Development Guide
Nitin Giri
Ā 
PDF
Workshop 12: AngularJS Parte I
Visual Engineering
Ā 
PPTX
Training On Angular Js
Mahima Radhakrishnan
Ā 
PDF
AngularJS Basics
Ravi Mone
Ā 
PDF
An introduction to AngularJS
Yogesh singh
Ā 
PPTX
Basics of AngularJS
Filip Janevski
Ā 
PPTX
AngularJS Introduction, how to run Angular
SamuelJohnpeter
Ā 
PPTX
Angular Javascript Tutorial with command
ssuser42b933
Ā 
PPTX
Angularjs
Sabin Tamrakar
Ā 
PDF
AngularJS
NexThoughts Technologies
Ā 
PPTX
Angular js
vu van quyet
Ā 
PPTX
Dive into Angular, part 1: Introduction
Oleksii Prohonnyi
Ā 
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
Ā 
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
Ā 
Kalp Corporate Angular Js Tutorials
Kalp Corporate
Ā 
Dive into AngularJS and directives
Tricode (part of Dept)
Ā 
AngularJS is awesome
Eusebiu Schipor
Ā 
Angularjs basic part01
Mohd Abdul Baquee
Ā 
Angular js
ParmarAnisha
Ā 
ANGULARJS introduction components services and directives
SanthoshB77
Ā 
Angular workshop - Full Development Guide
Nitin Giri
Ā 
Workshop 12: AngularJS Parte I
Visual Engineering
Ā 
Training On Angular Js
Mahima Radhakrishnan
Ā 
AngularJS Basics
Ravi Mone
Ā 
An introduction to AngularJS
Yogesh singh
Ā 
Basics of AngularJS
Filip Janevski
Ā 
AngularJS Introduction, how to run Angular
SamuelJohnpeter
Ā 
Angular Javascript Tutorial with command
ssuser42b933
Ā 
Angularjs
Sabin Tamrakar
Ā 
Angular js
vu van quyet
Ā 
Dive into Angular, part 1: Introduction
Oleksii Prohonnyi
Ā 

Recently uploaded (20)

PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
AVTRON Technologies LLC
Ā 
PDF
Software Development Methodologies in 2025
KodekX
Ā 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
Ā 
PDF
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
Ā 
PDF
Software Development Company | KodekX
KodekX
Ā 
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
Ā 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
Ā 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
Ā 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
DOCX
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
Ā 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
Ā 
PDF
NewMind AI Monthly Chronicles - July 2025
NewMind AI
Ā 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
Ā 
PDF
Doc9.....................................
SofiaCollazos
Ā 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 
PDF
Test Bank, Solutions for Java How to Program, An Objects-Natural Approach, 12...
famaw19526
Ā 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
Ā 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
Ā 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
AVTRON Technologies LLC
Ā 
Software Development Methodologies in 2025
KodekX
Ā 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
Ā 
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
Ā 
Software Development Company | KodekX
KodekX
Ā 
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
Ā 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
Ā 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
Ā 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
Ā 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
Ā 
NewMind AI Monthly Chronicles - July 2025
NewMind AI
Ā 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
Ā 
Doc9.....................................
SofiaCollazos
Ā 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 
Test Bank, Solutions for Java How to Program, An Objects-Natural Approach, 12...
famaw19526
Ā 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
Ā 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
Ā 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 

Intoduction to Angularjs

  • 1. ANGULARJS By Gaurav Agrawal HTML enhanced for web apps!
  • 2. What is ANGULARJS? • AngularJS is an open source javascript based web application framework. (Current stable version 1.4.8 ) • It’s not a JavaScript library (As they say) but a framework. There are no functions which we can directly call and use. • Focus more on HTML side of web apps. • For MVC/MVVM design pattern
  • 3. Key Features • AngularJS is a powerful JavaScript based development framework to create RICH Internet Application(RIA). • It provides developers options to write client side application (using JavaScript) in a clean MVC(Model View Controller) way. • Applications written in AngularJS is cross-browser compliant. It automatically handles JavaScript code suitable for each browser. • It is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache License version 2.0. • Overall, AngularJS is a framework to build large scale and high performance web application while keeping them as easy-to-maintain.
  • 4. Why ANGULARJS? • It defines numerous ways to organize web application at client side. • It Enhances HTML by attaching directives, custom tags, attributes, expressions, templates within HTML. • Encourage MVC/MVVM design pattern • Code Reuse • Good for Single Page Apps (SPA) - Single-Page Applications (SPAs) are Web apps that load a singleHTML page and dynamically update that page as the user interacts with the app. SPAs use AJAX and HTML5 to create fluid and responsive Web apps, without constant page reloads. (eg: Gmail)
  • 5. Core Features of ANGULARJS • Easy Data Binding : Two way Data Binding • Reusable Components • MVC/MVVM Design Pattern • End to end Integration Testing / Unit Testing • Cross-browser compliant • Services • Expressions • Filters • Directives • Form Validation • Modular
  • 6. 2 Way Data Binding Data binding is an AngularJS feature that automatically synchronizes your model data with your HTML. Whenever the HTML is changed the model gets updated and wherever the model gets updated it is reflected in HTML.
  • 7. Identify MVC in Angular Js
  • 8. Execution ā€œWelcome AngularJS to the world of Tutorialspoint!ā€ When the page is loaded in the browser, following things happen āˆ’ • HTML document is loaded into the browser, and evaluated by the browser. AngularJS JavaScript file is loaded, the angular global object is created. Next, JavaScript which registers controller functions is executed. • Next AngularJS scans through the HTML to look for AngularJS apps and views. Once view is located, it connects that view to the corresponding controller function. • Next, AngularJS executes the controller functions. It then renders the views with data from the model populated by the controller. The page is now ready.
  • 9. Steps to create Angular App Step 1 āˆ’ Load framework Being a pure JavaScript framework, It can be added using <Script> tag. <script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"> </script> Step 2 āˆ’ Define AngularJS Application using ng-app directive <div ng-app = ""> ... </div> Step 3 āˆ’ Define a model name using ng-model directive <p>Enter your Name: <input type = "text" ng-model = "name"></p> Step 4 āˆ’ Bind the value of above model defined using ng-bind directive. <p>Hello <span ng-bind = "name"></span>!</p>
  • 10. Directive (teaches HTML new tricks.) The directives can be placed in element names, attributes, class names, as well as comments. Directives are a way to teach HTML new tricks. A directive is just a function which executes when the compiler encounters it in the DOM. <input ng-model='name'> Custom Defined Directives <span draggable>Drag ME</span>
  • 11. How AngularJS integrates with HTML ng-app directive indicates the start of AngularJS application. ng-model(two way) The ngModel directive binds an input, select, textarea (or custom form control) to a property on the scope. ($scope --> view and view --> $scope) ng-bind(one way) The ngBind attribute tells Angular to replace the text content of the specified HTML element(div or p or span) with the value of a given expression, and to update the text content when the value of that expression changes. ($scope --> view) Closing</div> tag indicates the end of AngularJS application.
  • 12. Expression AngularJS will "output" data exactly where the expression is written. {{ expression }} <body> 1+2={{1+2}} </body> Alternative is to use ā€˜ng-bind’ directive.
  • 13. Module (the modular approach) AngularJS supports modular approach. Modules are used to separate logics say services, controllers, etc. and keep the code clean. We define modules in separate js files and name them as per the module.js file. eg: 1)mainApp.js var mainApp = angular.module("mainApp", []); var mainApp2 = angular.module("mainApp2", []); 2)Controller.js mainApp.controller("studentController", function($scope) {………………} Here we've declared a controller studentController module using mainApp.controller function.
  • 14. Use Module <div ng-app = "mainAppā€œ> <div ng-controller = "studentController"></div> <div ng-controller = ā€œotherController"></div> </div> Here we've used application module using ng-app directive and controller using ng- controller directive. We've imported mainApp.js and studentController.js in the main html page.
  • 15. Services (reusable singleton object ) In AngularJS, services are reusable singleton objects that are used to organize and share code across your app. They can be injected into controllers, filters and directives. AngularJS provides you three ways to create services: service, factory and provider. Only one Instance of service is available within the app. For example, after a successful login, you'll need to store the login status where the status can be retrieved in all other components. In this scenario, you can store the status in a service and then, whenever you need to read the value, you can just inject it into your controller/service and check it. AngularJS provides many inbuilt services for example, $http, $route, $window, $location etc. Each service is responsible for a specific task for example, $http is used to make ajax call to get the server data. $route is used to define the routing information and so on. Inbuilt services are always prefixed with $ symbol.
  • 16. Why we need Service ? ā€œIf You wish to share business logic between controllersā€ Two of the five SOLID principles of object oriented design are directly related to Services: the Single Responsibility Principle (SRP) and the Dependency Inversion Principle (DIP). The single responsibility principle teaches that every object should have a single responsibility. If we use the example of a controller, it’s responsibility is essentially to wire up the scope (which holds your models) to your view; it is essentially the bridge between your models and your views. If your controller is also responsible for making ajax calls to fetch and update data, this is a violation of the SRP principle. Logic like that (and other business logic) should instead be abstracted out into a separate service, then injected into the objects that need to use it.
  • 17. Factories vs. Services First, right off the bat I’ll say they’re pretty much equivalent. Why do we have them both, then? They both allow us to create an object that can then be used anywhere in our app. Most important is to realize that both are singletons in your app. Essentially, factories are functions that return the object, while services are constructor functions of the object which are instantiated with the new keyword. http://blog.thoughtram.io/angular/2015/07/07/service-vs-factory-once-and-for-all.html http://www.codelord.net/2015/04/28/angularjs-whats-the-difference-between-factory-and-service/
  • 18. Scope (the owner of application variables and functions) $scope: It is an object that contains all the data to which HTML is bound. They act as the glue for your javascript code (controllers) and the view (HTML). Everything that is attached to the $scope, it is automatically watched by AngularJS and updated. <script> var mainApp = angular.module(ā€œmyApp", []); mainApp.controller("shapeController", function($scope) { $scope.message = "In shape controller"; $scope.type = "Shape"; }); </script>
  • 19. Controllers(a JavaScript Object) Controllers is a JavaScript Object, created by a standard JavaScript object constructor. AngularJS application mainly relies on controllers to control the flow of data in the application. A controller is defined using ng-controller directive. Each controller accepts $scope as a parameter which refers to the application/module that controller is to control. <div ng-app = "" ng-controller = "studentController"> ... </div> Here we've declared a controller studentController using ng-controller directive.
  • 20. Filters Selects a subset of items from array and returns it as a new array. Angular filters format data for display to the user. {{ expression [| filter_name[:parameter_value] ... ] }} {{ uppercase_expression | uppercase }} {{ expression | filter1 | filter2 }} Can create custom filters
  • 21. Advantages of AngularJS • It provides the capability to create Single Page Application in a very clean and maintainable way. • It provides data binding capability to HTML. Thus, it gives user a rich and responsive experience. • AngularJS code is unit testable. • AngularJS uses dependency injection and make use of separation of concerns. • AngularJS provides reusable components. • With AngularJS, the developers can achieve more functionality with short code. • In AngularJS, views are pure html pages, and controllers written in JavaScript do the business processing.
  • 22. Disadvantages of AngularJS Though AngularJS comes with a lot of merits, here are some points of concern: 1. Not secure : Being JavaScript only framework, application written in AngularJS are not safe. Server side authentication and authorization is must to keep an application secure. 2. Not degradable: If the user of your application disables JavaScript, then nothing would be visible, except the basic page.
  • 23. Summary If you compare jQuery and Angular, the former is a library and the latter is a framework. You can plug the library in your project and either use it fully, partially or not use it all. It’s like a plugin, a supplement to your JS project. With a framework – you have to play by its rules, either use it fully or don’t use it all. Angular.js is a MVC framework, it has model, view and controller which is one of the most popular software development architectures today. When developing with Angular, you have to start from the ground up with your architecture in mind. Angular doesn’t replace jQuery, it doesn’t compete with jQuery, they both can be used in the same application. jQuery for DOM manipulation, Angular – for structure. In fact there is nothing better to do DOM manipulation than jQuery.
  • 24. Resources Documentation • AngularJS Developer Guide • AngularJS API • AngularJS Tutorial Videos • AngularJS Fundamentals In 60-ish Minutes • Introduction to Angular JS • AngularJS end-to-end web app tutorial Part I