SlideShare a Scribd company logo
Starting with Angular
JS
JAGRITI SRIVASTAVA
A simple html page without angularjs
<!DOCTYPE html>
<html>
<head>
<title>Angular - Demos</title>
<meta charset="utf-8" />
</head>
<body>
<div id="messageTitle"></div>
<div id="message">Hello World</div>
</body>
</html>
• In this case this html page shows
a single view .
• This is a Single Page Application,
only a portion of the page
represents the current view.
• In this case, the contents of the
body represent the view while the
HTML and HEAD elements make
up the container for the individual
views.
• To make it angular js application
there are some steps to follow.
Steps for Angular JS application
 Reference angular js framework
 Define the angular js application
 To define angular js application there are some components to be used
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
ng-app − This directive defines and links an AngularJS application to HTML.
ng-model − This directive binds the values of AngularJS application data to HTML input
controls.
ng-bind − This directive binds the AngularJS Application data to HTML tags.
 When this script loads it will examine the page and look for directives such
as the ng-view used previously.
 To bootstrap the application an ng-app directive is used, typically on the
HTML element itself.
 When AngularJS loads it will see this directive which will cause it to look for
a module named “hackApp.”
<html ng-app="hackApp">
 This single line of code defines module named “hackApp,” which will also
be used to connect controllers to the application.
 The script needs to then be referenced in the index.html page so the ng-
app directive and the module can be connected.
var hackApp = angular.module("hackApp", []);
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="scripts/ngHackApp.js"></script>
 Viewing the page in a browser results in a simple view, which shows the
heading and the static message contained in the view.
 It needs a controller and model to actually make it more than just some
HTML markup.
 The controller will be responsible for connecting the view and model and
resolves other dependencies like:
 services to consume HTTP resources.
 So the overall program with controller and view will be like this
<!DOCTYPE html>
<html ng-app="hackApp">
<head>
<title>Hack Hands Angular - Demos</title>
<meta charset="utf-8" />
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="scripts/ngHackApp.js"></script>
</head>
<body ng-controller="indexController">
<h1>Hack Hands Angular Demos</h1>
<div ng-view>
<div id="messageTitle"></div>
<div id="message">Hello World</div>
</div>
</body>
</html>
 Here ng-controller and ng-view will be working as view and controller for angularjs MVC
platform
 The ng-controller must be registered with the ANGULARJS application in order to be
resolvable by name.
 One way to register the controller is to manually add it to the JavaScript variable
representing the AngularJS application.
var indexController = hackApp.controller("indexController", function ($scope) {
// controller logic goes here
}
);
 The $scope is the dependency of the controller called the $scope object.
 The $scope parameter refers to the current scope or context for the view.
 $scope is the model used by the view.
 The model for a controller contains the data to be displayed, as well as
data to be collected in any input fields or forms.
 models may contain functions that are invoked based on user input or
other activities like clicking a button or making changes to the model data.
 The $scope object injected into the controller can be used as the model directly
 $scope can be used to declare and set a value on the model.
 AngularJS provides a rich declarative data binding experience. That means elements in
the view can have their value bound to the model.
var indexController = hackApp.controller("indexController", function
($scope) {
// controller logic goes here
$scope.message = "Hello Hacking World"
}
);
 The binding in AngularJS is two-way,
 The value can be changed by the view (e.g. changing the value in a text box) or in the model
(e.g. changing the model in a function when a button is clicked).
<div ng-view>
<div id="messageTitle"></div>
<div id="message">Hello {{message}}!</div>
<form>
<input type="text" id="name" ng-model="message" />
</form>
</div>
Using two way data binding
<form>
<input type="text" id="name" ng-model="message" />
<button ng-click="popupGreet()" value="popup">Greet</button>
</form>
var indexController = hackApp.controller("indexController", function ($scope,
$window) {
// controller logic goes here
$scope.message = "Hello Hacking World";
$scope.popupGreet = function () {
$window.alert("Hi there " + $scope.message);
};
}
);

More Related Content

What's hot (19)

PPTX
Angular js
ParmarAnisha
 
PDF
Angular js
Knoldus Inc.
 
PPTX
Introduction to AngularJS Framework
Raveendra R
 
DOCX
AngularJS
Ermir Hoxhaj
 
PPTX
Angular Js Get Started - Complete Course
EPAM Systems
 
PPTX
Angular js
Dinusha Nandika
 
PPTX
Dive into Angular, part 5: Experience
Oleksii Prohonnyi
 
PDF
Angularjs tutorial
HarikaReddy115
 
PPTX
Training On Angular Js
Mahima Radhakrishnan
 
PPTX
Why angular js Framework
Sakthi Bro
 
PPTX
Controllers in AngularJs
K Arunkumar
 
PDF
Angular from Scratch
Christian Lilley
 
PPTX
Angular Js Basics
أحمد عبد الوهاب
 
PPTX
Angular js
sanjay joshi
 
DOCX
Different way to share data between controllers in angular js
codeandyou forums
 
PDF
Gettings started with the superheroic JavaScript library AngularJS
Armin Vieweg
 
PPTX
Understanding angular js
Aayush Shrestha
 
PPTX
Dive into Angular, part 2: Architecture
Oleksii Prohonnyi
 
Angular js
ParmarAnisha
 
Angular js
Knoldus Inc.
 
Introduction to AngularJS Framework
Raveendra R
 
AngularJS
Ermir Hoxhaj
 
Angular Js Get Started - Complete Course
EPAM Systems
 
Angular js
Dinusha Nandika
 
Dive into Angular, part 5: Experience
Oleksii Prohonnyi
 
Angularjs tutorial
HarikaReddy115
 
Training On Angular Js
Mahima Radhakrishnan
 
Why angular js Framework
Sakthi Bro
 
Controllers in AngularJs
K Arunkumar
 
Angular from Scratch
Christian Lilley
 
Angular Js Basics
أحمد عبد الوهاب
 
Angular js
sanjay joshi
 
Different way to share data between controllers in angular js
codeandyou forums
 
Gettings started with the superheroic JavaScript library AngularJS
Armin Vieweg
 
Understanding angular js
Aayush Shrestha
 
Dive into Angular, part 2: Architecture
Oleksii Prohonnyi
 

Similar to Starting with angular js (20)

PDF
Mobile phone future angular js
atanacy
 
PDF
Workshop 12: AngularJS Parte I
Visual Engineering
 
PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
PPTX
Angular js for Beginnners
Santosh Kumar Kar
 
PPTX
Angular workshop - Full Development Guide
Nitin Giri
 
PPTX
Basics of AngularJS
Filip Janevski
 
PPTX
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Jalal Mostafa
 
DOCX
ANGULAR JS LAB MANUAL(final) vtu2021 sch
kannikadg
 
PPTX
Angular js
Baldeep Sohal
 
PPTX
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
PPTX
AngularJs Basic Concept
Hari Haran
 
PDF
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
 
PPT
AngularJS Mobile Warsaw 20-10-2014
Dariusz Kalbarczyk
 
PPTX
Valentine with Angular js - Introduction
Senthil Kumar
 
PDF
AngularJS Basics
Ravi Mone
 
PPTX
Intoduction to Angularjs
Gaurav Agrawal
 
PDF
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PPTX
Angular Javascript Tutorial with command
ssuser42b933
 
PDF
An introduction to AngularJS
Yogesh singh
 
PPTX
ANGULARJS introduction components services and directives
SanthoshB77
 
Mobile phone future angular js
atanacy
 
Workshop 12: AngularJS Parte I
Visual Engineering
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
Angular js for Beginnners
Santosh Kumar Kar
 
Angular workshop - Full Development Guide
Nitin Giri
 
Basics of AngularJS
Filip Janevski
 
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Jalal Mostafa
 
ANGULAR JS LAB MANUAL(final) vtu2021 sch
kannikadg
 
Angular js
Baldeep Sohal
 
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
AngularJs Basic Concept
Hari Haran
 
Introduction to AngularJS By Bharat Makwana
Bharat Makwana
 
AngularJS Mobile Warsaw 20-10-2014
Dariusz Kalbarczyk
 
Valentine with Angular js - Introduction
Senthil Kumar
 
AngularJS Basics
Ravi Mone
 
Intoduction to Angularjs
Gaurav Agrawal
 
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Angular Javascript Tutorial with command
ssuser42b933
 
An introduction to AngularJS
Yogesh singh
 
ANGULARJS introduction components services and directives
SanthoshB77
 
Ad

More from jagriti srivastava (15)

PDF
Map reduce with big data
jagriti srivastava
 
PPTX
Oyo rooms
jagriti srivastava
 
PPTX
Information system of amazon
jagriti srivastava
 
PPTX
JavaScript Canvas
jagriti srivastava
 
PPTX
Variable and Methods in Java
jagriti srivastava
 
PPTX
Component diagram and Deployment Diagram
jagriti srivastava
 
PPTX
Basic java, java collection Framework and Date Time API
jagriti srivastava
 
PPTX
Form validation and animation
jagriti srivastava
 
PPTX
Custom directive and scopes
jagriti srivastava
 
PPTX
Angular directive filter and routing
jagriti srivastava
 
PPTX
Angular introduction basic
jagriti srivastava
 
PPTX
Scannerclass
jagriti srivastava
 
PPTX
Programming Workshop
jagriti srivastava
 
PPTX
Java Nested class Concept
jagriti srivastava
 
PPTX
Java , A brief Introduction
jagriti srivastava
 
Map reduce with big data
jagriti srivastava
 
Information system of amazon
jagriti srivastava
 
JavaScript Canvas
jagriti srivastava
 
Variable and Methods in Java
jagriti srivastava
 
Component diagram and Deployment Diagram
jagriti srivastava
 
Basic java, java collection Framework and Date Time API
jagriti srivastava
 
Form validation and animation
jagriti srivastava
 
Custom directive and scopes
jagriti srivastava
 
Angular directive filter and routing
jagriti srivastava
 
Angular introduction basic
jagriti srivastava
 
Scannerclass
jagriti srivastava
 
Programming Workshop
jagriti srivastava
 
Java Nested class Concept
jagriti srivastava
 
Java , A brief Introduction
jagriti srivastava
 
Ad

Recently uploaded (20)

PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 

Starting with angular js

  • 2. A simple html page without angularjs <!DOCTYPE html> <html> <head> <title>Angular - Demos</title> <meta charset="utf-8" /> </head> <body> <div id="messageTitle"></div> <div id="message">Hello World</div> </body> </html> • In this case this html page shows a single view . • This is a Single Page Application, only a portion of the page represents the current view. • In this case, the contents of the body represent the view while the HTML and HEAD elements make up the container for the individual views. • To make it angular js application there are some steps to follow.
  • 3. Steps for Angular JS application  Reference angular js framework  Define the angular js application  To define angular js application there are some components to be used <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> ng-app − This directive defines and links an AngularJS application to HTML. ng-model − This directive binds the values of AngularJS application data to HTML input controls. ng-bind − This directive binds the AngularJS Application data to HTML tags.
  • 4.  When this script loads it will examine the page and look for directives such as the ng-view used previously.  To bootstrap the application an ng-app directive is used, typically on the HTML element itself.  When AngularJS loads it will see this directive which will cause it to look for a module named “hackApp.” <html ng-app="hackApp">
  • 5.  This single line of code defines module named “hackApp,” which will also be used to connect controllers to the application.  The script needs to then be referenced in the index.html page so the ng- app directive and the module can be connected. var hackApp = angular.module("hackApp", []); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> <script src="scripts/ngHackApp.js"></script>
  • 6.  Viewing the page in a browser results in a simple view, which shows the heading and the static message contained in the view.  It needs a controller and model to actually make it more than just some HTML markup.  The controller will be responsible for connecting the view and model and resolves other dependencies like:  services to consume HTTP resources.
  • 7.  So the overall program with controller and view will be like this <!DOCTYPE html> <html ng-app="hackApp"> <head> <title>Hack Hands Angular - Demos</title> <meta charset="utf-8" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> <script src="scripts/ngHackApp.js"></script> </head> <body ng-controller="indexController"> <h1>Hack Hands Angular Demos</h1> <div ng-view> <div id="messageTitle"></div> <div id="message">Hello World</div> </div> </body> </html>
  • 8.  Here ng-controller and ng-view will be working as view and controller for angularjs MVC platform  The ng-controller must be registered with the ANGULARJS application in order to be resolvable by name.  One way to register the controller is to manually add it to the JavaScript variable representing the AngularJS application. var indexController = hackApp.controller("indexController", function ($scope) { // controller logic goes here } );
  • 9.  The $scope is the dependency of the controller called the $scope object.  The $scope parameter refers to the current scope or context for the view.  $scope is the model used by the view.  The model for a controller contains the data to be displayed, as well as data to be collected in any input fields or forms.  models may contain functions that are invoked based on user input or other activities like clicking a button or making changes to the model data.
  • 10.  The $scope object injected into the controller can be used as the model directly  $scope can be used to declare and set a value on the model.  AngularJS provides a rich declarative data binding experience. That means elements in the view can have their value bound to the model. var indexController = hackApp.controller("indexController", function ($scope) { // controller logic goes here $scope.message = "Hello Hacking World" } );
  • 11.  The binding in AngularJS is two-way,  The value can be changed by the view (e.g. changing the value in a text box) or in the model (e.g. changing the model in a function when a button is clicked). <div ng-view> <div id="messageTitle"></div> <div id="message">Hello {{message}}!</div> <form> <input type="text" id="name" ng-model="message" /> </form> </div>
  • 12. Using two way data binding <form> <input type="text" id="name" ng-model="message" /> <button ng-click="popupGreet()" value="popup">Greet</button> </form> var indexController = hackApp.controller("indexController", function ($scope, $window) { // controller logic goes here $scope.message = "Hello Hacking World"; $scope.popupGreet = function () { $window.alert("Hi there " + $scope.message); }; } );