SlideShare a Scribd company logo
An
Introduction to
AngularJS
By makitweb.com
AngularJS is a JavaScript MVC
framework developed by Google that
lets you build well structured, easily
testable, declarative and maintainable
front-end applications which provides
solutions to standard infrastructure
concerns.
Intro
AngularJS is a JavaScript MVC Framework that integrates two-way data binding,
Angular does one very specific job very well – that is, moving data around inside a
single-page application, dynamically updating the view as the data changes without
the need for specific listener code. If you have a website where this type of
functionality is important (there’s more and more of them now) then it might fit the
bill for you.
There are other JavaScript frameworks placed on the client to manage the flow of
data from the server to your application, like -
Backbone, Knockout, React, Meteor, Aurelia, etc.
How to Embed AngularJS in your page?
For including AngularJS to your page you first need to download AngularJS library
from its Official Website. After downloading the library copy or move the file to
your project folder. Then include the file within your page same as we include a
jQuery library or any other JavaScript file.
<script type="text/javascript" src="angular.min.js"></script>
Or you can directly include from CDN <script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
Example
<!DOCTYPE html>
<html lang="en" ng-app="">
<head >
<meta charset="UTF-8">
<title>First AngularJS program</title>
<script src="angular.min.js" type="text/javascript"></script>
</head>
<body>
<div> </div>
</body>
</html>
In HTML code, you may be noted that <html> tag contains ng-app attribute.
What is ng-app ?
ng-app is an AngularJS directive there are many such directives are available in
AngularJS. Here, ng prefix stands for Angular. the ng-app directive is a starting point
of AngularJS application.
Angular Framework first checks the ng-app directive within the HTML page. If its
found then Angular bootstrap itself and starts to manage the section of the page
that have a ng-app directive. Everything within the HTML tag section will be
managed by Angular.
Let’s do some Angular
Let’s compute the sum of 40 + 50.
<!DOCTYPE html>
<html lang="en" ng-app="">
<head >
<meta charset="UTF-8">
<title>First AngularJS program</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
</head>
<body >
<div >
40 + 50 = {{ 40+50 }}
</div>
</body>
</html>
Here, we use double curly braces {{ }} in Angular it means binding expressions.
Within that, we can specify any Angular expression.
In above code, 40+50 treated as an expression and add both values.
When we execute the above program, it will produce the following output –
40 + 50 = 90
Now let’s change ng-app directive position
in our current code
In our previous code <html> code contain ng-app directive. Let’s move the ng-app
directive position to <div> tag and add another <div> and it also contains an Angular
expression.
<!DOCTYPE html>
<html lang="en" >
<head >
<meta charset="UTF-8">
<title>First AngularJS program</title>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
</head>
<body>
<div ng-app="">
40 + 50 = {{ 40+50 }}
</div>
<div>
50 + 60 = {{ 50+60 }}
</div>
</body>
</html>
Here, ng-app directive only present in first <div> that means Angular going to
manage only that section of the page and any children element it contains. Angular is
not responsible for rest of the page that means second <div> element which
contains Angular expression is not been evaluated.
When we execute the above program, it will produce the following output –
40 + 50 = 90
50 + 60 = {{ 50+60 }}
Valid expressions
Using relational operator to create an
expression. It returns True or False
based on values.
<div ng-app="">
{{ 31 > 20 }}
{{ 43 < 50 }}
{{ 13 >= 23 }}
{{ 12 <= 40 }}
{{ 5 == 5 }}
{{ 4 != 5 }}
</div>
Its gives the following Output –
true
true
false
true
true
true
Using JavaScript object in expression
<div ng-app="">
{{ {name:'Yogesh',age:22}.name }}
</div>
Its gives the following Output –
Yogesh
JavaScript Array in expression
<div ng-app="">
{{ ['Yogesh','Sonarika','Vishal'][1] }}
</div>
Its gives the following Output –
Sonarika
Advantages
● Two-way Data binding
In AngularJS Framework Two-way data binding is an approach to synchronize the
data between model and view that means if there is any change made in the model
then the view will be updated.
While you can write a simple two-way data-binding event in jQuery, JavaScript MVC
libraries provide a more declarative (using HTML) way of connecting models to your
view.
Advantages
● Faster application Development
The MVC architecture ensures that the application development, testing &
maintenance is fast & quick! It helps in enhancing the productivity of the developers
too!
● Templating
Angular combines the template with information from the model and controller to
render the dynamic view that a user sees in the browser.
Advantages
● Greate for SPA (Single Page Application)
Single Page Application(SPA) is a web application that fits on a single web page with
dynamic actions without refreshing the page. Single Page Application interactions
can be handled without reaching the server. Single Page Application can improve
performance in several ways like loading time, using AJAX, easy to navigate pages
etc. End users will be more comfortable with Single Page Application, It is very easy
to navigate to different page and filter content.
● Supported by Google and a great development community.
Why?
To built more responsive web applications, full page refresh takes the time to built
up a connection with the server while AJAX is amazingly fast in fetching data from
already connected server. The community is awesome, it’s google.
Plus you can build an app like Gmail using it. I have listened from sources that
Google is reinventing its Gmail app using AngularJS and the new design will roll out
to soothe the eye of consumer and suit the needs of current web era.
Thanks!
yssyogesh@makitweb.com
@yssyogesh_singh on twitter
www.makitweb.com

More Related Content

What's hot (19)

PPTX
Introduction to Android Programming
Raveendra R
 
PPTX
10 practices that every developer needs to start right now
Caleb Jenkins
 
PDF
Progressive Web Application by Citytech
Ritwik Das
 
PPTX
Introduction to AngularJS Framework
Raveendra R
 
PDF
Integrating consumers IoT devices into Business Workflow
Yakov Fain
 
PDF
Angular JS - Develop Responsive Single Page Application
Edureka!
 
PDF
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Digamber Singh
 
PPT
Ajax & ASP.NET 2
Talal Alsubaie
 
PPTX
Training On Angular Js
Mahima Radhakrishnan
 
PDF
Introduction to React for Frontend Developers
Sergio Nakamura
 
PPTX
Angular js
Mindtree
 
PDF
AngularJS - introduction & how it works?
Alexe Bogdan
 
PPTX
AngularJS is awesome
Eusebiu Schipor
 
PPTX
AngularJS Scopes
Mohamed Elkhodary
 
PDF
Building mobile applications with Vaadin TouchKit
Sami Ekblad
 
PPTX
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
PDF
AngularJS
Hiten Pratap Singh
 
PDF
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
PPTX
Angular js PPT
Imtiyaz Ahmad Khan
 
Introduction to Android Programming
Raveendra R
 
10 practices that every developer needs to start right now
Caleb Jenkins
 
Progressive Web Application by Citytech
Ritwik Das
 
Introduction to AngularJS Framework
Raveendra R
 
Integrating consumers IoT devices into Business Workflow
Yakov Fain
 
Angular JS - Develop Responsive Single Page Application
Edureka!
 
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Digamber Singh
 
Ajax & ASP.NET 2
Talal Alsubaie
 
Training On Angular Js
Mahima Radhakrishnan
 
Introduction to React for Frontend Developers
Sergio Nakamura
 
Angular js
Mindtree
 
AngularJS - introduction & how it works?
Alexe Bogdan
 
AngularJS is awesome
Eusebiu Schipor
 
AngularJS Scopes
Mohamed Elkhodary
 
Building mobile applications with Vaadin TouchKit
Sami Ekblad
 
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
Angular js PPT
Imtiyaz Ahmad Khan
 

Viewers also liked (7)

PPTX
How important are meta tags in seo
Swati Sharma
 
DOC
Đột quỵ, tai biến là do huyết áp tăng cao
angelyn338
 
DOC
Final Resume
WASEEM KHAWAR
 
PDF
8 Techniques Every Parent with an Anxious Child Should Try
anxietyreliefforkids
 
PDF
reinventingmegalopolis
Heather McCall
 
PPTX
Occupational Outlook Handbook Ready Reference Instructional Guide
LA2015du
 
PPTX
Social media marketing
Kishore1412
 
How important are meta tags in seo
Swati Sharma
 
Đột quỵ, tai biến là do huyết áp tăng cao
angelyn338
 
Final Resume
WASEEM KHAWAR
 
8 Techniques Every Parent with an Anxious Child Should Try
anxietyreliefforkids
 
reinventingmegalopolis
Heather McCall
 
Occupational Outlook Handbook Ready Reference Instructional Guide
LA2015du
 
Social media marketing
Kishore1412
 
Ad

Similar to An introduction to AngularJS (20)

PPTX
Intoduction to Angularjs
Gaurav Agrawal
 
PPTX
Angular JS - Introduction
Sagar Acharya
 
PPTX
Angular tutorial
Rohit Gupta
 
PDF
One Weekend With AngularJS
Yashobanta Bai
 
PPTX
AngularJs Basic Concept
Hari Haran
 
PPTX
The Basics Angular JS
OrisysIndia
 
PDF
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PPTX
Angular js introduction
Praveen Gubbala
 
PPTX
Ajs ppt
Avyaya Tarnaka
 
PDF
Dive into AngularJS and directives
Tricode (part of Dept)
 
PPTX
Angular Javascript Tutorial with command
ssuser42b933
 
PPTX
Angular Js
Knoldus Inc.
 
PPTX
Angular JS, A dive to concepts
Abhishek Sur
 
PDF
Angular.js - An introduction for the unitiated
thehoagie
 
PPTX
Angular js anupama
Anupama Prabhudesai
 
PDF
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
 
PPTX
AngularJS Training Course in Delhi
APTRON
 
PDF
What are the reasons behind growing popularity of AngularJS.pdf
mohitd6
 
PPTX
Kalp Corporate Angular Js Tutorials
Kalp Corporate
 
Intoduction to Angularjs
Gaurav Agrawal
 
Angular JS - Introduction
Sagar Acharya
 
Angular tutorial
Rohit Gupta
 
One Weekend With AngularJS
Yashobanta Bai
 
AngularJs Basic Concept
Hari Haran
 
The Basics Angular JS
OrisysIndia
 
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Angular js introduction
Praveen Gubbala
 
Dive into AngularJS and directives
Tricode (part of Dept)
 
Angular Javascript Tutorial with command
ssuser42b933
 
Angular Js
Knoldus Inc.
 
Angular JS, A dive to concepts
Abhishek Sur
 
Angular.js - An introduction for the unitiated
thehoagie
 
Angular js anupama
Anupama Prabhudesai
 
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
 
AngularJS Training Course in Delhi
APTRON
 
What are the reasons behind growing popularity of AngularJS.pdf
mohitd6
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate
 
Ad

More from Yogesh singh (8)

PDF
How to create Custom Page Template in WordPress
Yogesh singh
 
PDF
Drag and drop file upload with Dropzone in CodeIgniter
Yogesh singh
 
PDF
Check username availability with vue.js and PHP
Yogesh singh
 
PDF
Copy text to clipboard using vue-clipboard2 - Vue.js
Yogesh singh
 
PDF
How to Create and Load Model in Laravel
Yogesh singh
 
PDF
Create custom 404 error page in CodeIgniter
Yogesh singh
 
PDF
How to Schedule Posts in Wordpress without Plugin
Yogesh singh
 
PDF
How to verify a domain in MailChimp
Yogesh singh
 
How to create Custom Page Template in WordPress
Yogesh singh
 
Drag and drop file upload with Dropzone in CodeIgniter
Yogesh singh
 
Check username availability with vue.js and PHP
Yogesh singh
 
Copy text to clipboard using vue-clipboard2 - Vue.js
Yogesh singh
 
How to Create and Load Model in Laravel
Yogesh singh
 
Create custom 404 error page in CodeIgniter
Yogesh singh
 
How to Schedule Posts in Wordpress without Plugin
Yogesh singh
 
How to verify a domain in MailChimp
Yogesh singh
 

Recently uploaded (20)

PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Horarios de distribución de agua en julio
pegazohn1978
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Controller Request and Response in Odoo18
Celine George
 
epi editorial commitee meeting presentation
MIPLM
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Difference between write and update in odoo 18
Celine George
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 

An introduction to AngularJS

  • 2. AngularJS is a JavaScript MVC framework developed by Google that lets you build well structured, easily testable, declarative and maintainable front-end applications which provides solutions to standard infrastructure concerns.
  • 3. Intro AngularJS is a JavaScript MVC Framework that integrates two-way data binding, Angular does one very specific job very well – that is, moving data around inside a single-page application, dynamically updating the view as the data changes without the need for specific listener code. If you have a website where this type of functionality is important (there’s more and more of them now) then it might fit the bill for you. There are other JavaScript frameworks placed on the client to manage the flow of data from the server to your application, like - Backbone, Knockout, React, Meteor, Aurelia, etc.
  • 4. How to Embed AngularJS in your page? For including AngularJS to your page you first need to download AngularJS library from its Official Website. After downloading the library copy or move the file to your project folder. Then include the file within your page same as we include a jQuery library or any other JavaScript file. <script type="text/javascript" src="angular.min.js"></script> Or you can directly include from CDN <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
  • 5. Example <!DOCTYPE html> <html lang="en" ng-app=""> <head > <meta charset="UTF-8"> <title>First AngularJS program</title> <script src="angular.min.js" type="text/javascript"></script> </head> <body> <div> </div> </body> </html> In HTML code, you may be noted that <html> tag contains ng-app attribute.
  • 6. What is ng-app ? ng-app is an AngularJS directive there are many such directives are available in AngularJS. Here, ng prefix stands for Angular. the ng-app directive is a starting point of AngularJS application. Angular Framework first checks the ng-app directive within the HTML page. If its found then Angular bootstrap itself and starts to manage the section of the page that have a ng-app directive. Everything within the HTML tag section will be managed by Angular.
  • 7. Let’s do some Angular Let’s compute the sum of 40 + 50. <!DOCTYPE html> <html lang="en" ng-app=""> <head > <meta charset="UTF-8"> <title>First AngularJS program</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script> </head> <body > <div > 40 + 50 = {{ 40+50 }} </div> </body> </html>
  • 8. Here, we use double curly braces {{ }} in Angular it means binding expressions. Within that, we can specify any Angular expression. In above code, 40+50 treated as an expression and add both values. When we execute the above program, it will produce the following output – 40 + 50 = 90
  • 9. Now let’s change ng-app directive position in our current code In our previous code <html> code contain ng-app directive. Let’s move the ng-app directive position to <div> tag and add another <div> and it also contains an Angular expression.
  • 10. <!DOCTYPE html> <html lang="en" > <head > <meta charset="UTF-8"> <title>First AngularJS program</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script> </head> <body> <div ng-app=""> 40 + 50 = {{ 40+50 }} </div> <div> 50 + 60 = {{ 50+60 }} </div> </body> </html>
  • 11. Here, ng-app directive only present in first <div> that means Angular going to manage only that section of the page and any children element it contains. Angular is not responsible for rest of the page that means second <div> element which contains Angular expression is not been evaluated. When we execute the above program, it will produce the following output – 40 + 50 = 90 50 + 60 = {{ 50+60 }}
  • 12. Valid expressions Using relational operator to create an expression. It returns True or False based on values. <div ng-app=""> {{ 31 > 20 }} {{ 43 < 50 }} {{ 13 >= 23 }} {{ 12 <= 40 }} {{ 5 == 5 }} {{ 4 != 5 }} </div> Its gives the following Output – true true false true true true
  • 13. Using JavaScript object in expression <div ng-app=""> {{ {name:'Yogesh',age:22}.name }} </div> Its gives the following Output – Yogesh JavaScript Array in expression <div ng-app=""> {{ ['Yogesh','Sonarika','Vishal'][1] }} </div> Its gives the following Output – Sonarika
  • 14. Advantages ● Two-way Data binding In AngularJS Framework Two-way data binding is an approach to synchronize the data between model and view that means if there is any change made in the model then the view will be updated. While you can write a simple two-way data-binding event in jQuery, JavaScript MVC libraries provide a more declarative (using HTML) way of connecting models to your view.
  • 15. Advantages ● Faster application Development The MVC architecture ensures that the application development, testing & maintenance is fast & quick! It helps in enhancing the productivity of the developers too! ● Templating Angular combines the template with information from the model and controller to render the dynamic view that a user sees in the browser.
  • 16. Advantages ● Greate for SPA (Single Page Application) Single Page Application(SPA) is a web application that fits on a single web page with dynamic actions without refreshing the page. Single Page Application interactions can be handled without reaching the server. Single Page Application can improve performance in several ways like loading time, using AJAX, easy to navigate pages etc. End users will be more comfortable with Single Page Application, It is very easy to navigate to different page and filter content. ● Supported by Google and a great development community.
  • 17. Why? To built more responsive web applications, full page refresh takes the time to built up a connection with the server while AJAX is amazingly fast in fetching data from already connected server. The community is awesome, it’s google. Plus you can build an app like Gmail using it. I have listened from sources that Google is reinventing its Gmail app using AngularJS and the new design will roll out to soothe the eye of consumer and suit the needs of current web era.