SlideShare a Scribd company logo
1 of 33
ANGULAR JS
Anisha
INTRODUCTION
• Angular JS is a JavaScript.
• Added to an HTML page with a <script> tag.
• Extends HTML attributes with Directives.
• Binds data with Expressions.
• Used in Single Page Application (SPA) projects.

CORE FEATURES
WHY USE ANGULAR JS???
 Data-binding
 Dependency Injection
 MVC Framework
 Two-way data binding
 SPA(Single Page Application)
Example of Two Way Data Binding:
TWO WAY DATA BINDING
DIRECTIVE
Today’s HTML Component
ANGULARJS COMPONENTS/ DIRECTIVE
• ng-app − This directive initializes an AngularJS
application.
<div ng-app="">
• ng-model − This directive binds the values of AngularJS
application data to HTML input controls (input, select,
textarea) of our application .
ng-model="name"
• ng-bind − This directive binds the AngularJS
Application data to HTML tags.
ng-bind="name"
MODEL
The structure of your Application
NG-MODEL DIRECTIVE
 ng-model directive you can bind the value of an
input field to a variable created in AngularJS.
 Example:
<div ng-app="myApp" ng-controller="myCtrl">
Name: <input ng-model="name">
</div>
NG-BIND DIRECTIVE
 ng-bind directive, which will bind the innerHTML of
the element to the specified model property
 Example:
<p ng-bind="firstname"></p>
</div>
<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind="name"></p>
</div>
NG-REPEAT DIRECTIVE
 The ng-repeat directive repeats a set of HTML, a given
number of times.
 Syntax:
<element ng-repeat="expression"></element>
 Legal Expression examples:
x in records
(key, value) in myObj
Example:
<TR NG-REPEAT="X IN RECORDS">
<TD>{{X.NAME}}</TD>
<TD>{{X.COUNTRY}}</TD>
</TR>
<SCRIPT>
VAR APP = ANGULAR.MODULE("MYAPP", []);
APP.CONTROLLER("MYCTRL", FUNCTION($SCOPE) {
$SCOPE.RECORDS = [
{
"NAME" : "ALFREDS FUTTERKISTE",
"COUNTRY" : "GERMANY"
}, {
"NAME" : "BERGLUNDS SNABBKÖP",
"COUNTRY" : "SWEDEN"
} ]
});
</SCRIPT>
<TABLE NG-CONTROLLER="MYCTRL" BORDER="1">
<TR NG-REPEAT="(X, Y) IN MYOBJ">
<TD>{{X}}</TD>
<TD>{{Y}}</TD>
</TR>
</TABLE>
<SCRIPT>
VAR APP = ANGULAR.MODULE("MYAPP", []);
APP.CONTROLLER("MYCTRL", FUNCTION($SCOPE) {
$SCOPE.MYOBJ = {
"NAME" : "ALFREDS FUTTERKISTE",
"COUNTRY" : "GERMANY",
"CITY" : "BERLIN"
}
});
</SCRIPT>
EXPRESSIONS
Bind your Data anywhere in the page
ANGULARJS EXPRESSIONS
 AngularJS binds data to HTML
using Expressions.
 AngularJS expressions can be written inside
double braces: {{ expression }}.
 AngularJS expressions can also be written
inside a directive: ng-bind="expression".
My first expression: {{ 5 + 5 }}
ANGULARJS MODULES
 An AngularJS module defines an application.
 The module is a container for the application
controllers.
 A module is created by using the AngularJS
function angular.module
 Example:
<div ng-app="myApp">...</div>
<script>
var app = angular.module("myApp", []);
</script>
<div ng-app="myApp">...</div>
<script>
var app = angular.module("myApp", []);
</script>
CONTROLLERS
Data provider for our view
ANGULARJS CONTROLLERS
 AngularJS applications are controlled by controllers. They act as
containers.
 The ng-controller directive defines the application controller.
 Example:
<div ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe"; });
</script>
<div ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-
model="firstName"><br>
Last Name: <input type="text" ng-
model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe"; });
</script>
CONTROLLERS IN EXTERNAL FILES
 In larger applications, it is common to store
controllers in external files.
 Example:
<div ng-app="myApp" ng-
controller="personCtrl">
First Name: <input type="text" ng-
model="firstName"><br>
Last Name: <input type="text" ng-
model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<script src="personController.js"></script>
<div ng-app="myApp" ng-controller="personCtrl">
First Name: <input type="text" ng-
model="firstName"><br>
Last Name: <input type="text" ng-
model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<script src="personController.js"></script>
PERSONCONTROLLER.JS
 app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " +
$scope.lastName;
};
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " +
$scope.lastName;
};
ANGULARJS SCOPE
 The scope is the binding part between the HTML (view)
and the JavaScript (controller).
 Example:
<div ng-app="myApp" ng-
controller="myCtrl">
<h1>{{carname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
});
</script>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>{{carname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
});
</script>
SERVICES
Utility component of our Application
ANGULARJS SERVICES
 $http Service
 The service makes a request to the server, and lets your
application handle the response.
 Example:
$http.get("welcome.htm").then(function (resp
onse) {
$scope.myWelcome = response.data;
});
});
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http)
{
$http.get("welcome.htm").then(function (response) {
$scope.myWelcome = response.data;
});
});
$TIMEOUT SERVICE
 $timeout Service
o The $timeout service is AngularJS' version of
the window.setTimeout function.
o Example:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope,
$timeout) {
$scope.myHeader = "Hello World!";
$timeout(function () {
$scope.myHeader = "How are you today?";
}, 2000);
});
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope,
$timeout) {
$scope.myHeader = "Hello World!";
$timeout(function () {
$scope.myHeader = "How are you today?";
}, 2000);
});
FILTERS
Change the way your expressions are displayed
UPPERCASE FILTER
 Syntax:
{{student.fullName() | uppercase}}
LOWERCASE FILTER
 Syntax:
{{student.fullName() | lowercase}}
ORDERBY FILTER
 Syntax:
<li ng-repeat = "subject in student.subjects |
orderBy:'marks'">
DEMO LOGIN FORM
PROJECT STRUCTURE
SPA WITH CRUD OPERATION
THANK YOU

More Related Content

What's hot

What's hot (20)

Angular js PPT
Angular js PPTAngular js PPT
Angular js PPT
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from Scratch
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
Angular js
Angular jsAngular js
Angular js
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorial
 
Directives
DirectivesDirectives
Directives
 
Angular JS
Angular JSAngular JS
Angular JS
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
 

Viewers also liked

Design Patterns
Design PatternsDesign Patterns
Design Patterns
soms_1
 

Viewers also liked (15)

Angular js
Angular jsAngular js
Angular js
 
Design patterns through refactoring
Design patterns through refactoringDesign patterns through refactoring
Design patterns through refactoring
 
Design Patterns in .Net
Design Patterns in .NetDesign Patterns in .Net
Design Patterns in .Net
 
Creational Design Patterns
Creational Design PatternsCreational Design Patterns
Creational Design Patterns
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Get satrted angular js
Get satrted angular jsGet satrted angular js
Get satrted angular js
 
Angular 2
Angular 2Angular 2
Angular 2
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
Object-oriented design patterns  in UML [Software Modeling] [Computer Science...Object-oriented design patterns  in UML [Software Modeling] [Computer Science...
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
 
Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
 

Similar to Angular js

Similar to Angular js (20)

Angular js
Angular jsAngular js
Angular js
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014
 
AngularJs
AngularJsAngularJs
AngularJs
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
 
Dive into AngularJS and directives
Dive into AngularJS and directivesDive into AngularJS and directives
Dive into AngularJS and directives
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routing
 
Angular js - 4developers 12 kwietnia 2013
Angular js - 4developers 12 kwietnia 2013Angular js - 4developers 12 kwietnia 2013
Angular js - 4developers 12 kwietnia 2013
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Single Page Applications Workshop Part II: Single Page Applications using Ang...Single Page Applications Workshop Part II: Single Page Applications using Ang...
Single Page Applications Workshop Part II: Single Page Applications using Ang...
 
Angular js
Angular jsAngular js
Angular js
 
Custom directive and scopes
Custom directive and scopesCustom directive and scopes
Custom directive and scopes
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
 
Angular
AngularAngular
Angular
 
Angular
AngularAngular
Angular
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By Vipin
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 

Angular js

  • 2. INTRODUCTION • Angular JS is a JavaScript. • Added to an HTML page with a <script> tag. • Extends HTML attributes with Directives. • Binds data with Expressions. • Used in Single Page Application (SPA) projects. 
  • 4. WHY USE ANGULAR JS???  Data-binding  Dependency Injection  MVC Framework  Two-way data binding  SPA(Single Page Application)
  • 5. Example of Two Way Data Binding:
  • 6. TWO WAY DATA BINDING
  • 8. ANGULARJS COMPONENTS/ DIRECTIVE • ng-app − This directive initializes an AngularJS application. <div ng-app=""> • ng-model − This directive binds the values of AngularJS application data to HTML input controls (input, select, textarea) of our application . ng-model="name" • ng-bind − This directive binds the AngularJS Application data to HTML tags. ng-bind="name"
  • 9. MODEL The structure of your Application
  • 10. NG-MODEL DIRECTIVE  ng-model directive you can bind the value of an input field to a variable created in AngularJS.  Example: <div ng-app="myApp" ng-controller="myCtrl"> Name: <input ng-model="name"> </div>
  • 11. NG-BIND DIRECTIVE  ng-bind directive, which will bind the innerHTML of the element to the specified model property  Example: <p ng-bind="firstname"></p> </div> <div ng-app="myApp" ng-controller="myCtrl"> <p ng-bind="name"></p> </div>
  • 12. NG-REPEAT DIRECTIVE  The ng-repeat directive repeats a set of HTML, a given number of times.  Syntax: <element ng-repeat="expression"></element>  Legal Expression examples: x in records (key, value) in myObj Example:
  • 13. <TR NG-REPEAT="X IN RECORDS"> <TD>{{X.NAME}}</TD> <TD>{{X.COUNTRY}}</TD> </TR> <SCRIPT> VAR APP = ANGULAR.MODULE("MYAPP", []); APP.CONTROLLER("MYCTRL", FUNCTION($SCOPE) { $SCOPE.RECORDS = [ { "NAME" : "ALFREDS FUTTERKISTE", "COUNTRY" : "GERMANY" }, { "NAME" : "BERGLUNDS SNABBKÖP", "COUNTRY" : "SWEDEN" } ] }); </SCRIPT>
  • 14. <TABLE NG-CONTROLLER="MYCTRL" BORDER="1"> <TR NG-REPEAT="(X, Y) IN MYOBJ"> <TD>{{X}}</TD> <TD>{{Y}}</TD> </TR> </TABLE> <SCRIPT> VAR APP = ANGULAR.MODULE("MYAPP", []); APP.CONTROLLER("MYCTRL", FUNCTION($SCOPE) { $SCOPE.MYOBJ = { "NAME" : "ALFREDS FUTTERKISTE", "COUNTRY" : "GERMANY", "CITY" : "BERLIN" } }); </SCRIPT>
  • 15. EXPRESSIONS Bind your Data anywhere in the page
  • 16. ANGULARJS EXPRESSIONS  AngularJS binds data to HTML using Expressions.  AngularJS expressions can be written inside double braces: {{ expression }}.  AngularJS expressions can also be written inside a directive: ng-bind="expression". My first expression: {{ 5 + 5 }}
  • 17. ANGULARJS MODULES  An AngularJS module defines an application.  The module is a container for the application controllers.  A module is created by using the AngularJS function angular.module  Example: <div ng-app="myApp">...</div> <script> var app = angular.module("myApp", []); </script> <div ng-app="myApp">...</div> <script> var app = angular.module("myApp", []); </script>
  • 19. ANGULARJS CONTROLLERS  AngularJS applications are controlled by controllers. They act as containers.  The ng-controller directive defines the application controller.  Example: <div ng-app="myApp" ng-controller="myCtrl"> First Name: <input type="text" ng-model="firstName"><br> Last Name: <input type="text" ng-model="lastName"><br> <br> Full Name: {{firstName + " " + lastName}} </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.firstName = "John"; $scope.lastName = "Doe"; }); </script> <div ng-app="myApp" ng-controller="myCtrl"> First Name: <input type="text" ng- model="firstName"><br> Last Name: <input type="text" ng- model="lastName"><br> <br> Full Name: {{firstName + " " + lastName}} </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.firstName = "John"; $scope.lastName = "Doe"; }); </script>
  • 20. CONTROLLERS IN EXTERNAL FILES  In larger applications, it is common to store controllers in external files.  Example: <div ng-app="myApp" ng- controller="personCtrl"> First Name: <input type="text" ng- model="firstName"><br> Last Name: <input type="text" ng- model="lastName"><br> <br> Full Name: {{fullName()}} </div> <script src="personController.js"></script> <div ng-app="myApp" ng-controller="personCtrl"> First Name: <input type="text" ng- model="firstName"><br> Last Name: <input type="text" ng- model="lastName"><br> <br> Full Name: {{fullName()}} </div> <script src="personController.js"></script>
  • 21. PERSONCONTROLLER.JS  app.controller('personCtrl', function($scope) { $scope.firstName = "John"; $scope.lastName = "Doe"; $scope.fullName = function() { return $scope.firstName + " " + $scope.lastName; }; app.controller('personCtrl', function($scope) { $scope.firstName = "John"; $scope.lastName = "Doe"; $scope.fullName = function() { return $scope.firstName + " " + $scope.lastName; };
  • 22. ANGULARJS SCOPE  The scope is the binding part between the HTML (view) and the JavaScript (controller).  Example: <div ng-app="myApp" ng- controller="myCtrl"> <h1>{{carname}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.carname = "Volvo"; }); </script> <div ng-app="myApp" ng-controller="myCtrl"> <h1>{{carname}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.carname = "Volvo"; }); </script>
  • 23. SERVICES Utility component of our Application
  • 24. ANGULARJS SERVICES  $http Service  The service makes a request to the server, and lets your application handle the response.  Example: $http.get("welcome.htm").then(function (resp onse) { $scope.myWelcome = response.data; }); }); var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $http) { $http.get("welcome.htm").then(function (response) { $scope.myWelcome = response.data; }); });
  • 25. $TIMEOUT SERVICE  $timeout Service o The $timeout service is AngularJS' version of the window.setTimeout function. o Example: var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $timeout) { $scope.myHeader = "Hello World!"; $timeout(function () { $scope.myHeader = "How are you today?"; }, 2000); }); var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $timeout) { $scope.myHeader = "Hello World!"; $timeout(function () { $scope.myHeader = "How are you today?"; }, 2000); });
  • 26. FILTERS Change the way your expressions are displayed
  • 27. UPPERCASE FILTER  Syntax: {{student.fullName() | uppercase}} LOWERCASE FILTER  Syntax: {{student.fullName() | lowercase}} ORDERBY FILTER  Syntax: <li ng-repeat = "subject in student.subjects | orderBy:'marks'">
  • 30. SPA WITH CRUD OPERATION
  • 31.
  • 32.