SlideShare a Scribd company logo
AngularJS
AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your
template language and lets you extend HTML's syntax to express your application's
components clearly and succinctly. Angular's data binding and dependency injection
eliminate much of the code you would otherwise have to write. And it all happens within the
browser, making it an ideal partner with any server technology.
AngularJS is a JavaScript framework. It is a library written in JavaScript.
AngularJS is distributed as a JavaScript file, and can be added to a web page with a script
tag:
AngularJS is a JavaScript framework for organizing HTML code in a more structural. This
client-side technology provides easy and light code in order to make developing and even
designing as a simple task.
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></scrip
t>
AngularJS Extends:
The ng-app directive defines an AngularJS application.
The ng-model directive binds the value of HTML controls (input, select, textarea) to
application data.
The ng-bind directive binds application data to the HTML view.
Sample Example:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div ng-app="">
<p>Name:
<asp:TextBox ID="txtname" runat="server" ng-model="name">
</asp:TextBox>
</p>
<p ng-bind="name"></p>
</div>
</form>
</body>
</html>
AngularJS starts automatically when the web page has loaded.
The ng-init directive initialize AngularJS application variables.
ng-init Example:
<div ng-app="" ng-init="firstName='Prasad'">
<p>The name is <span ng-bind="firstName"></span></p>
</div>
AngularJS Expressions:
1) AngularJS expressions are written inside double braces: {{ expression }}.
2) AngularJS expressions binds data to HTML the same way as the ng-bind directive.
3) AngularJS will "output" data exactly where the expression is written.
Example:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div ng-app="">
<p>My first expression: {{ 5 + 5 }}</p>
</div>
</div>
</form>
</body>
</html>
AngularJS Numbers: AngularJS numbers are like JavaScript numbers:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div ng-app="" ng-init="quantity=1;price=5">
Quantity:
<asp:TextBox ID="txtquality" runat="server" type="number" ng-
model="quantity"></asp:TextBox>
Costs:
<asp:TextBox ID="txtprice" runat="server" type="number" ng-
model="price"></asp:TextBox>
Total in dollar: {{ quantity * price }}
</div>
</form>
</body>
</html>
AngularJS Strings: AngularJS strings are like JavaScript strings:
Example:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div ng-app="" ng-init="firstName='Prasad';lastName='D'">
<p>The name is {{ firstName + " " + lastName }}</p>
OR
<p>The name is <span ng-bind="firstName + ' ' + lastName"></span></p>
</div>
</form>
</body>
</html>
AngularJS Objects: AngularJS objects are like JavaScript objects:
Example:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1”>
<div ng-app="" ng-init="person={firstName:'Prasad',lastName:'D'}">
<p>The name is {{ person.lastName }}</p>
</div>
</form>
</body>
</html>
AngularJS Arrays: AngularJS arrays are like JavaScript arrays:
Var obj=[2,4,6];
Example:
<!DOCTYPE html>
<html">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div ng-app="" ng-init="numbers= [1,3,5,6,8]">
<p>The third result is: {{points[3]}}</p>
<p>The third result is <span ng-bind="numbers [2]"></span></p>
</div>
</form>
</body>
</html>
AngularJS Directives:
1) The ng-app directive initializes an AngularJS application.
2) The ng-init directive initializes application data.
3) The ng-model directive binds the value of HTML controls to application data.
Example:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div ng-app="" ng-init="firstName='Prasad';lastName='D'">
<p>The name is {{ firstName + " " + lastName }}</p>
</div>
</form>
</body>
</html>
Repeating HTML Elements: The ng-repeat directive repeats an HTML element:
Example: display multiple rows and columns data using looping.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div ng-app="" ng-init=" names=[{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]">
<ul>
<li ng-repeat="y in names">{{ y.name + ', ' + y.country }}
</li>
</ul>
</div>
</form>
</body>
</html>
AngularJS Controllers:
A controller is a JavaScript Object, created by a standard JavaScript object
constructor. AngularJS applications are controlled by controllers. The ng-
controller directive defines the application controller.
Example:
<!DOCTYPE html>
<html">
<head>
<title></title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<form id="form1">
<div ng-app="myApp" ng-controller="myCtrl">
First Name: <asp:TextBox ID="txtfname" runat="server"
ng-model="firstName"></asp:TextBox><br>
Last Name: <asp:TextBox ID="txtlname" runat="server"
ng-model="lastName"></asp:TextBox><br>
<br>
Full Name: {{firstName + " " + lastName}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "Prasad";
$scope.lastName = "D";
});
</script>
</form>
</body>
</html>
Controller Methods: A controller can also have methods (variables as functions):
<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>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
}
});
</script>
AngularJS Filters: AngularJS filters can be used to transform data:
Filter Description
Currency Format a number to a currency format
Filter Select a subset of items from an array.
Lowercase Format a string to lowercase.
Uppercase Format a string to uppercase.
orderBy Order an array by an expression.
Adding Filters to Expressions
A filter can be added to an expression with a pipe character (|) and a filter.
The uppercase filter format strings to upper case:
The lowercase filter format strings to lower case:
Example: uppercase-lowercase.html
The currency Filter :
The currency filter formats a number as currency:
Example : currency-filter.html
Filters to Directives
A filter can be added to a directive with a pipe character (|) and a filter.
The orderBy filter orders an array by an expression:
Example : filter-directives.html
Filtering Input : An input filter can be added to a directive with a pipe character (|) and
filter followed by a colon and a model name.
The filter filter selects a subset of an array:
Example: filter-input.html
AngularJS AJAX - $http :
AngularJS $http is a core service for reading data from web servers.
$http.get(url) is the function to use for reading server data.
Example : angularjs-http-get.html
The AngularJS application is defined by ng-app. The application runs inside a <div>.
The ng-controller directive names the controller object.
The customersCtrl function is a standard JavaScript object constructor.
AngularJS will invoke customersCtrl with a $scope and $http object.
$scope is the application object (the owner of application variables and functions).
$http is an XMLHttpRequest object for requesting external data.
$http.get() reads JSON data from http://www.w3schools.com/angular/customers.php.
If success, the controller creates a property (names) in the scope, with JSON data from
the server.
Displaying Data in a Table :
We can display data in table format using ng-repeat directive. It is perfect for displaying
tables.
Example: angularjs-tables.html
<table>
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
Displaying with CSS Style
To make it nice, add some CSS to the page:
Example : angularjs-tables.html
Display with orderBy Filter
To sort the table, add an orderBy filter:
Example :
<table>
<tr ng-repeat="x in names | orderBy : 'Country'">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
Display with uppercase Filter :
To display uppercase, add an uppercase filter:
Example:
<table>
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.Country | uppercase }}</td>
</tr>
</table>
Table Index ($index): To display the table index, add a <td> with $index:
Example:
<table>
<tr ng-repeat="x in names">
<td>{{ $index + 1 }}</td>
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
AngularJS Example Application with SqlServer
AngularJS HTML DOM : The ng-disabled directive binds AngularJS application data to the
disabled attribute of HTML elements.
Example : angularjs-disabled.html
<div ng-app="">
<p>
<button ng-disabled="mySwitch">Click Me!</button>
</p><p>
<input type="checkbox" ng-model="mySwitch">Button
</p>
</div>
The ng-disabled directive binds the application data mySwitch to the HTML
button's disabled attribute.
The ng-model directive binds the value of the HTML checkbox element to the value
of mySwitch.
If the value of mySwitch evaluates to true, the button will be disabled:
The ng-show Directive
The ng-show directive shows or hides an HTML element.
Example: angularjs-ng-show.html
<div ng-app="">
<p ng-show="true">I am visible.</p>
<p ng-show="false">I am not visible.</p>
</div>
The ng-show directive shows (or hides) an HTML element based on the value of ng-show.
You can use any expression that evaluates to true or false:
AngularJS Events :
The ng-click Directive :
The ng-click directive defines an AngularJS click event.
Example : angularjs-ng-click.html
<div ng-app="" ng-controller="myCtrl">
<button ng-click="count = count + 1">Click me!</button>
<p>{{ count }}</p>
</div>
Hiding HTML Elements :
The ng-hide directive can be used to set the visibility of a part of an application.
The value ng-hide="true" makes an HTML element invisible.
The value ng-hide="false" makes the element visible.
Example : angularjs-ng-hide.html
The first part of the personController is the same as in the chapter about controllers.
The application has a default property (a variable): $scope.myVar = false;
The ng-hide directive sets the visibility, of a <p> element with two input fields,
according to the value (true or false) of myVar.
The function toggle() toggles myVar between true and false.
The value ng-hide="true" makes the element invisible.
Showing HTML Elements :
The ng-show directive can also be used to set the visibility of a part of an application.
The value ng-show="false" makes an HTML element invisible.
The value ng-show="true" makes the element visible.
Here is the same example as above, using ng-show instead of ng-hide:
Example: angularjs-ng-show.html
<div ng-app="myApp" ng-controller="personCtrl">
<button ng-click="toggle()">Toggle</button>
<p ng-show="myVar">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "Harish",
$scope.lastName = "G"
$scope.myVar = true;
$scope.toggle = function() {
$scope.myVar = !$scope.myVar;
}
});
</script>
AngularJS Modules :
An AngularJS module defines an application.
A module is a container for the different parts of an application.
All application controllers should belong to a module.
A Module With One Controller
This application ("myApp"), has one controller ("myCtrl"):
Example: modules examples
Modules and Controllers in Files :
It is common in AngularJS applications to put the module and the controllers in JavaScript
files. In this example, "myApp.js" contains an application module definition, while
"myCtrl.js" contains the controller:
Forms in AngularJS :
An AngularJS form is a collection of input controls.
HTML Controls
HTML input elements are called HTML controls:
 input elements
 select elements
 button elements
 textarea elements
Example : angularjs-forms.html
The ng-app directive defines the AngularJS application.
The ng-controller directive defines the application controller.
The ng-model directive binds two input elements to the user object in the model.
The formCtrl function sets initial values to the master object, and defines
the reset() method.
The reset() method sets the user object equal to the master object.
The ng-click directive invokes the reset() method, only if the button is clicked.
AngularJS Input Validation : AngularJS forms and controls can provide validation
services, and notify users of invalid input.
Example: angularjs-validations.html
AngularJS API : API stands for Application Programming Interface.
AngularJS Global API :
The AngularJS Global API is a set of global JavaScript functions for performing common
tasks like:
 Comparing objects
 Iterating objects
 Converting data
The Global API functions are accessed using the angular object.
API Description
Angular.lowecase() Converts a string to lowercase.
Angular.uppercase() Converts a string to uppercase.
Angular.isString() Returns true if the reference is a string.
Angular.isNumber() Returns true if the reference is a number.
Service and factory, custom directory, templates
Custome Directives : Custom directives are used in AngularJS to extend the functionality
of HTML. Custom directives are defined using "directive" function. A custom directive simply
replaces the element for which it is activated. AngularJS provides support to create custom
directives for following type of elements.
 Element directives - Directive activates when a matching element is encountered.
 Attribute - - Directive activates when a matching attribute is encountered.
 CSS - - Directive activates when a matching css style is encountered.
 Comment - - Directive activates when a matching comment is encountered.
Example : angularjs-custom-directives.html
Services & Factory :
Factory : A factory is a simple function which allows you to add some logic before creating
object. It returns the created object.
Syntax: app.factory(‘servicename’,function(){return serviceObj;})
Example :
module.factory('userService', function(){
var fac = {};
fac.users = ['John', 'James', 'Jake'];
return fac;
});
Services : A service is a construction function which creates the object using new keyword.
You can add properties and functions to a service object by using this keyword.
Example : services-example.html
AngularJS Templates: In Angular, templates are the views with the HTML enriched by
Angular elements like directive and attributes. Templates are used to display the
information from the model and controller that a user sees in his browser.
There are 2 types of templates :
1) Static Templates : A static template is defined by using script tag. It must has an id attribute
with a unique value and a type attribute with value text/ng-template. Also, a static template
must be inside the scope of the ng-app directive otherwise it will be ignored by Angular.
Example : static-templates.html
2) Dynamic Templates : A dynamic template is an html page which is compiled and rendered by
Angular on demand.
Example : dynamic-templates.html
$watch()
The $scope.watch() function creates a watch of some variable. When you register a
watch you pass two functions as parameters to the $watch() function:
 A value function
 A listener function
$scope.$watch(function() {},
function() {}
);
The first function is the value function and the second function is the listener function.
The value function should return the value which is being watched. AngularJS can then check
the value returned against the value the watch function returned the last time. That way
AngularJS can determine if the value has changed. Here is an example:
$scope.$watch(function(scope) { return scope.data.myVar },
function() {}
);
http://www.dotnet-tricks.com/Tutorial/angularjs/V2YS090914-Understanding-
AngularJS-Factory,-Service-and-Provider.html
What is AngularJS?
Ans: AngularJS is a javascript framework used for creating single web page
applications. It simplifies binding javascript objects with HTML ui elements. It allows
you to use html as your template language and enables you to extend HTML’s syntax to
express your application’s components clearly.
What are key the features of Angularjs?
Ans: Model, View, Controller, Directives, Filters, Scope, Services, Data Binding.
What is a directive in AngularJS and what are different types of directives?
Ans: Directives are attributes decorated on the HTML elements. All directives start with
the word “ng”. As the name says directive it directs angular what to do.
During compilation process when special HTML constructs are encountered a function is
triggered, this function is referred as directive. It is executed when the compiler
encounters it in the DOM.
1) Element Directive
2) Attribute Directive
3) CSS class Directive
4) Comment Directive
What are the advantages of angularjs?
Ans:
1) AngularJS supports MVC pattern.
2) Using angularjs can do 2 ways binding.
3) It has pre-defined form validations.
4) It supports client-server communications.
5) It supports animations.
What is “$rootScope” and how is it related with “$scope”?
Ans: “$rootScope” is a parent object of all “$scope” angular objects created in a
webpage.
How is the data binding in angularjs?
Ans: its two way binding. So whenever you make changes in one entity the other entity
also gets updated.

More Related Content

What's hot

Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
Aayush Shrestha
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
priya Nithya
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
Filip Janevski
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014
Dariusz Kalbarczyk
 
AngularJS
AngularJSAngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
Narek Mamikonyan
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
stephskardal
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
Morteza Zohoori Shoar
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBDynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Apaichon Punopas
 
jQuery and AJAX with Rails
jQuery and AJAX with RailsjQuery and AJAX with Rails
jQuery and AJAX with Rails
Alan Hecht
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
Sagar Acharya
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
 
Angular js
Angular jsAngular js
Angular js
Dinusha Nandika
 
jQuery Ajax
jQuery AjaxjQuery Ajax
jQuery Ajax
Anand Kumar Rajana
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction
Diego Scataglini
 
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
Simon Guest
 

What's hot (19)

Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
 
Angular js
Angular jsAngular js
Angular js
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
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 training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBDynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
 
jQuery and AJAX with Rails
jQuery and AJAX with RailsjQuery and AJAX with Rails
jQuery and AJAX with Rails
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Angular js
Angular jsAngular js
Angular js
 
jQuery Ajax
jQuery AjaxjQuery Ajax
jQuery Ajax
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction
 
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
 

Viewers also liked

Angularjs interview questions and answers
Angularjs interview questions and answersAngularjs interview questions and answers
Angularjs interview questions and answers
prasaddammalapati
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJSBlake Newman
 
Laravel Blade
Laravel BladeLaravel Blade
Laravel Blade
Julien TANT
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
Confiz
 
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
Shekhar Gulati
 
Introduction to Browser DOM
Introduction to Browser DOMIntroduction to Browser DOM
Introduction to Browser DOMSiva Arunachalam
 
Open shift for java(ee) developers
Open shift for java(ee) developersOpen shift for java(ee) developers
Open shift for java(ee) developersShekhar Gulati
 
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
OPITZ CONSULTING Deutschland
 
AngularJS & Job
AngularJS & JobAngularJS & Job
AngularJS & Jobganesgo
 
Surviving as a Professional Software Developer
Surviving as a Professional Software DeveloperSurviving as a Professional Software Developer
Surviving as a Professional Software Developer
Yakov Fain
 
Java EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaJava EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest Austria
Shekhar Gulati
 
Bringing spatial love to your python application
Bringing spatial love to your python applicationBringing spatial love to your python application
Bringing spatial love to your python application
Shekhar Gulati
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsShekhar Gulati
 
Simple Mobile Development With Ionic - Ondrisek
Simple Mobile Development With Ionic - OndrisekSimple Mobile Development With Ionic - Ondrisek
Simple Mobile Development With Ionic - Ondrisek
Barbara Ondrisek
 
Indic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudIndic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudShekhar Gulati
 
Becoming a professional software developer
Becoming a professional software developerBecoming a professional software developer
Becoming a professional software developer
Yakov Fain
 
Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)
Florence Davis
 
Working effectively with OpenShift
Working effectively with OpenShiftWorking effectively with OpenShift
Working effectively with OpenShift
Shekhar Gulati
 

Viewers also liked (20)

Angularjs interview questions and answers
Angularjs interview questions and answersAngularjs interview questions and answers
Angularjs interview questions and answers
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJS
 
Laravel Blade
Laravel BladeLaravel Blade
Laravel Blade
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
 
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
 
Introduction to Browser DOM
Introduction to Browser DOMIntroduction to Browser DOM
Introduction to Browser DOM
 
Open shift for java(ee) developers
Open shift for java(ee) developersOpen shift for java(ee) developers
Open shift for java(ee) developers
 
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
 
AngularJS & Job
AngularJS & JobAngularJS & Job
AngularJS & Job
 
Surviving as a Professional Software Developer
Surviving as a Professional Software DeveloperSurviving as a Professional Software Developer
Surviving as a Professional Software Developer
 
Java EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaJava EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest Austria
 
Bringing spatial love to your python application
Bringing spatial love to your python applicationBringing spatial love to your python application
Bringing spatial love to your python application
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
 
Hicss 42 Presentation
Hicss 42 PresentationHicss 42 Presentation
Hicss 42 Presentation
 
Simple Mobile Development With Ionic - Ondrisek
Simple Mobile Development With Ionic - OndrisekSimple Mobile Development With Ionic - Ondrisek
Simple Mobile Development With Ionic - Ondrisek
 
Indic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudIndic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloud
 
Becoming a professional software developer
Becoming a professional software developerBecoming a professional software developer
Becoming a professional software developer
 
Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)
 
Working effectively with OpenShift
Working effectively with OpenShiftWorking effectively with OpenShift
Working effectively with OpenShift
 

Similar to Angular js

Angular js
Angular jsAngular js
Angular js
Steve Fort
 
Angular js
Angular jsAngular js
Angular js
ParmarAnisha
 
Dive into AngularJS and directives
Dive into AngularJS and directivesDive into AngularJS and directives
Dive into AngularJS and directives
Tricode (part of Dept)
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
Visual Engineering
 
AngularJs
AngularJsAngularJs
AngularJs
syam kumar kk
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
OrisysIndia
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routing
jagriti srivastava
 
Introduction to angular js july 6th 2014
Introduction to angular js   july 6th 2014Introduction to angular js   july 6th 2014
Introduction to angular js july 6th 2014Simona Clapan
 
Custom directive and scopes
Custom directive and scopesCustom directive and scopes
Custom directive and scopes
jagriti srivastava
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
Brajesh Yadav
 
intro to Angular js
intro to Angular jsintro to Angular js
intro to Angular js
Brian Atkins
 
Starting with angular js
Starting with angular js Starting with angular js
Starting with angular js
jagriti srivastava
 
AngularJS Introduction, how to run Angular
AngularJS Introduction, how to run AngularAngularJS Introduction, how to run Angular
AngularJS Introduction, how to run Angular
SamuelJohnpeter
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
Chandra Sekar
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By Vipin
Vipin Mundayad
 
Angular js
Angular jsAngular js
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
fakeaccount225095
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
Seungkyun Nam
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 

Similar to Angular js (20)

Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
Dive into AngularJS and directives
Dive into AngularJS and directivesDive into AngularJS and directives
Dive into AngularJS and directives
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
 
AngularJs
AngularJsAngularJs
AngularJs
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routing
 
Introduction to angular js july 6th 2014
Introduction to angular js   july 6th 2014Introduction to angular js   july 6th 2014
Introduction to angular js july 6th 2014
 
Custom directive and scopes
Custom directive and scopesCustom directive and scopes
Custom directive and scopes
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
 
intro to Angular js
intro to Angular jsintro to Angular js
intro to Angular js
 
Starting with angular js
Starting with angular js Starting with angular js
Starting with angular js
 
AngularJS Introduction, how to run Angular
AngularJS Introduction, how to run AngularAngularJS Introduction, how to run Angular
AngularJS Introduction, how to run Angular
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By Vipin
 
Angular js
Angular jsAngular js
Angular js
 
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 

Recently uploaded

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
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
WSO2
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 

Recently uploaded (20)

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
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
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 

Angular js

  • 1. AngularJS AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you would otherwise have to write. And it all happens within the browser, making it an ideal partner with any server technology. AngularJS is a JavaScript framework. It is a library written in JavaScript. AngularJS is distributed as a JavaScript file, and can be added to a web page with a script tag: AngularJS is a JavaScript framework for organizing HTML code in a more structural. This client-side technology provides easy and light code in order to make developing and even designing as a simple task. <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></scrip t> AngularJS Extends: The ng-app directive defines an AngularJS application. The ng-model directive binds the value of HTML controls (input, select, textarea) to application data. The ng-bind directive binds application data to the HTML view. Sample Example: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1" runat="server"> <div ng-app=""> <p>Name: <asp:TextBox ID="txtname" runat="server" ng-model="name"> </asp:TextBox> </p> <p ng-bind="name"></p> </div> </form> </body> </html> AngularJS starts automatically when the web page has loaded. The ng-init directive initialize AngularJS application variables. ng-init Example:
  • 2. <div ng-app="" ng-init="firstName='Prasad'"> <p>The name is <span ng-bind="firstName"></span></p> </div> AngularJS Expressions: 1) AngularJS expressions are written inside double braces: {{ expression }}. 2) AngularJS expressions binds data to HTML the same way as the ng-bind directive. 3) AngularJS will "output" data exactly where the expression is written. Example: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1" runat="server"> <div> <div ng-app=""> <p>My first expression: {{ 5 + 5 }}</p> </div> </div> </form> </body> </html> AngularJS Numbers: AngularJS numbers are like JavaScript numbers: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1" runat="server"> <div ng-app="" ng-init="quantity=1;price=5"> Quantity: <asp:TextBox ID="txtquality" runat="server" type="number" ng- model="quantity"></asp:TextBox> Costs: <asp:TextBox ID="txtprice" runat="server" type="number" ng- model="price"></asp:TextBox> Total in dollar: {{ quantity * price }} </div> </form>
  • 3. </body> </html> AngularJS Strings: AngularJS strings are like JavaScript strings: Example: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1" runat="server"> <div ng-app="" ng-init="firstName='Prasad';lastName='D'"> <p>The name is {{ firstName + " " + lastName }}</p> OR <p>The name is <span ng-bind="firstName + ' ' + lastName"></span></p> </div> </form> </body> </html> AngularJS Objects: AngularJS objects are like JavaScript objects: Example: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1”> <div ng-app="" ng-init="person={firstName:'Prasad',lastName:'D'}"> <p>The name is {{ person.lastName }}</p> </div> </form> </body> </html> AngularJS Arrays: AngularJS arrays are like JavaScript arrays: Var obj=[2,4,6]; Example: <!DOCTYPE html> <html"> <head runat="server"> <title></title>
  • 4. <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1" runat="server"> <div ng-app="" ng-init="numbers= [1,3,5,6,8]"> <p>The third result is: {{points[3]}}</p> <p>The third result is <span ng-bind="numbers [2]"></span></p> </div> </form> </body> </html> AngularJS Directives: 1) The ng-app directive initializes an AngularJS application. 2) The ng-init directive initializes application data. 3) The ng-model directive binds the value of HTML controls to application data. Example: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1" runat="server"> <div ng-app="" ng-init="firstName='Prasad';lastName='D'"> <p>The name is {{ firstName + " " + lastName }}</p> </div> </form> </body> </html> Repeating HTML Elements: The ng-repeat directive repeats an HTML element: Example: display multiple rows and columns data using looping. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1" runat="server"> <div ng-app="" ng-init=" names=[{name:'Jani',country:'Norway'}, {name:'Hege',country:'Sweden'},
  • 5. {name:'Kai',country:'Denmark'}]"> <ul> <li ng-repeat="y in names">{{ y.name + ', ' + y.country }} </li> </ul> </div> </form> </body> </html> AngularJS Controllers: A controller is a JavaScript Object, created by a standard JavaScript object constructor. AngularJS applications are controlled by controllers. The ng- controller directive defines the application controller. Example: <!DOCTYPE html> <html"> <head> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <form id="form1"> <div ng-app="myApp" ng-controller="myCtrl"> First Name: <asp:TextBox ID="txtfname" runat="server" ng-model="firstName"></asp:TextBox><br> Last Name: <asp:TextBox ID="txtlname" runat="server" ng-model="lastName"></asp:TextBox><br> <br> Full Name: {{firstName + " " + lastName}} </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.firstName = "Prasad"; $scope.lastName = "D"; }); </script> </form> </body> </html> Controller Methods: A controller can also have methods (variables as functions): <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()}}
  • 6. </div> <script> var app = angular.module('myApp', []); app.controller('personCtrl', function($scope) { $scope.firstName = "John"; $scope.lastName = "Doe"; $scope.fullName = function() { return $scope.firstName + " " + $scope.lastName; } }); </script> AngularJS Filters: AngularJS filters can be used to transform data: Filter Description Currency Format a number to a currency format Filter Select a subset of items from an array. Lowercase Format a string to lowercase. Uppercase Format a string to uppercase. orderBy Order an array by an expression. Adding Filters to Expressions A filter can be added to an expression with a pipe character (|) and a filter. The uppercase filter format strings to upper case: The lowercase filter format strings to lower case: Example: uppercase-lowercase.html The currency Filter : The currency filter formats a number as currency: Example : currency-filter.html Filters to Directives A filter can be added to a directive with a pipe character (|) and a filter. The orderBy filter orders an array by an expression: Example : filter-directives.html Filtering Input : An input filter can be added to a directive with a pipe character (|) and filter followed by a colon and a model name. The filter filter selects a subset of an array: Example: filter-input.html AngularJS AJAX - $http : AngularJS $http is a core service for reading data from web servers. $http.get(url) is the function to use for reading server data. Example : angularjs-http-get.html
  • 7. The AngularJS application is defined by ng-app. The application runs inside a <div>. The ng-controller directive names the controller object. The customersCtrl function is a standard JavaScript object constructor. AngularJS will invoke customersCtrl with a $scope and $http object. $scope is the application object (the owner of application variables and functions). $http is an XMLHttpRequest object for requesting external data. $http.get() reads JSON data from http://www.w3schools.com/angular/customers.php. If success, the controller creates a property (names) in the scope, with JSON data from the server. Displaying Data in a Table : We can display data in table format using ng-repeat directive. It is perfect for displaying tables. Example: angularjs-tables.html <table> <tr ng-repeat="x in names"> <td>{{ x.Name }}</td> <td>{{ x.Country }}</td> </tr> </table> Displaying with CSS Style To make it nice, add some CSS to the page: Example : angularjs-tables.html Display with orderBy Filter To sort the table, add an orderBy filter: Example : <table> <tr ng-repeat="x in names | orderBy : 'Country'"> <td>{{ x.Name }}</td> <td>{{ x.Country }}</td> </tr> </table> Display with uppercase Filter : To display uppercase, add an uppercase filter: Example: <table> <tr ng-repeat="x in names"> <td>{{ x.Name }}</td> <td>{{ x.Country | uppercase }}</td> </tr> </table> Table Index ($index): To display the table index, add a <td> with $index: Example:
  • 8. <table> <tr ng-repeat="x in names"> <td>{{ $index + 1 }}</td> <td>{{ x.Name }}</td> <td>{{ x.Country }}</td> </tr> </table> AngularJS Example Application with SqlServer AngularJS HTML DOM : The ng-disabled directive binds AngularJS application data to the disabled attribute of HTML elements. Example : angularjs-disabled.html <div ng-app=""> <p> <button ng-disabled="mySwitch">Click Me!</button> </p><p> <input type="checkbox" ng-model="mySwitch">Button </p> </div> The ng-disabled directive binds the application data mySwitch to the HTML button's disabled attribute. The ng-model directive binds the value of the HTML checkbox element to the value of mySwitch. If the value of mySwitch evaluates to true, the button will be disabled: The ng-show Directive The ng-show directive shows or hides an HTML element. Example: angularjs-ng-show.html <div ng-app=""> <p ng-show="true">I am visible.</p> <p ng-show="false">I am not visible.</p> </div> The ng-show directive shows (or hides) an HTML element based on the value of ng-show. You can use any expression that evaluates to true or false: AngularJS Events : The ng-click Directive : The ng-click directive defines an AngularJS click event. Example : angularjs-ng-click.html <div ng-app="" ng-controller="myCtrl"> <button ng-click="count = count + 1">Click me!</button>
  • 9. <p>{{ count }}</p> </div> Hiding HTML Elements : The ng-hide directive can be used to set the visibility of a part of an application. The value ng-hide="true" makes an HTML element invisible. The value ng-hide="false" makes the element visible. Example : angularjs-ng-hide.html The first part of the personController is the same as in the chapter about controllers. The application has a default property (a variable): $scope.myVar = false; The ng-hide directive sets the visibility, of a <p> element with two input fields, according to the value (true or false) of myVar. The function toggle() toggles myVar between true and false. The value ng-hide="true" makes the element invisible. Showing HTML Elements : The ng-show directive can also be used to set the visibility of a part of an application. The value ng-show="false" makes an HTML element invisible. The value ng-show="true" makes the element visible. Here is the same example as above, using ng-show instead of ng-hide: Example: angularjs-ng-show.html <div ng-app="myApp" ng-controller="personCtrl"> <button ng-click="toggle()">Toggle</button> <p ng-show="myVar"> First Name: <input type="text" ng-model="firstName"><br> Last Name: <input type="text" ng-model="lastName"><br> <br> Full Name: {{firstName + " " + lastName}} </p> </div> <script> var app = angular.module('myApp', []); app.controller('personCtrl', function($scope) { $scope.firstName = "Harish", $scope.lastName = "G" $scope.myVar = true; $scope.toggle = function() { $scope.myVar = !$scope.myVar; } }); </script> AngularJS Modules : An AngularJS module defines an application. A module is a container for the different parts of an application. All application controllers should belong to a module.
  • 10. A Module With One Controller This application ("myApp"), has one controller ("myCtrl"): Example: modules examples Modules and Controllers in Files : It is common in AngularJS applications to put the module and the controllers in JavaScript files. In this example, "myApp.js" contains an application module definition, while "myCtrl.js" contains the controller: Forms in AngularJS : An AngularJS form is a collection of input controls. HTML Controls HTML input elements are called HTML controls:  input elements  select elements  button elements  textarea elements Example : angularjs-forms.html The ng-app directive defines the AngularJS application. The ng-controller directive defines the application controller. The ng-model directive binds two input elements to the user object in the model. The formCtrl function sets initial values to the master object, and defines the reset() method. The reset() method sets the user object equal to the master object. The ng-click directive invokes the reset() method, only if the button is clicked. AngularJS Input Validation : AngularJS forms and controls can provide validation services, and notify users of invalid input. Example: angularjs-validations.html AngularJS API : API stands for Application Programming Interface. AngularJS Global API : The AngularJS Global API is a set of global JavaScript functions for performing common tasks like:  Comparing objects  Iterating objects  Converting data The Global API functions are accessed using the angular object. API Description Angular.lowecase() Converts a string to lowercase.
  • 11. Angular.uppercase() Converts a string to uppercase. Angular.isString() Returns true if the reference is a string. Angular.isNumber() Returns true if the reference is a number. Service and factory, custom directory, templates Custome Directives : Custom directives are used in AngularJS to extend the functionality of HTML. Custom directives are defined using "directive" function. A custom directive simply replaces the element for which it is activated. AngularJS provides support to create custom directives for following type of elements.  Element directives - Directive activates when a matching element is encountered.  Attribute - - Directive activates when a matching attribute is encountered.  CSS - - Directive activates when a matching css style is encountered.  Comment - - Directive activates when a matching comment is encountered. Example : angularjs-custom-directives.html Services & Factory : Factory : A factory is a simple function which allows you to add some logic before creating object. It returns the created object. Syntax: app.factory(‘servicename’,function(){return serviceObj;}) Example : module.factory('userService', function(){ var fac = {}; fac.users = ['John', 'James', 'Jake']; return fac; }); Services : A service is a construction function which creates the object using new keyword. You can add properties and functions to a service object by using this keyword. Example : services-example.html AngularJS Templates: In Angular, templates are the views with the HTML enriched by Angular elements like directive and attributes. Templates are used to display the information from the model and controller that a user sees in his browser. There are 2 types of templates : 1) Static Templates : A static template is defined by using script tag. It must has an id attribute with a unique value and a type attribute with value text/ng-template. Also, a static template must be inside the scope of the ng-app directive otherwise it will be ignored by Angular. Example : static-templates.html
  • 12. 2) Dynamic Templates : A dynamic template is an html page which is compiled and rendered by Angular on demand. Example : dynamic-templates.html $watch() The $scope.watch() function creates a watch of some variable. When you register a watch you pass two functions as parameters to the $watch() function:  A value function  A listener function $scope.$watch(function() {}, function() {} ); The first function is the value function and the second function is the listener function. The value function should return the value which is being watched. AngularJS can then check the value returned against the value the watch function returned the last time. That way AngularJS can determine if the value has changed. Here is an example: $scope.$watch(function(scope) { return scope.data.myVar }, function() {} ); http://www.dotnet-tricks.com/Tutorial/angularjs/V2YS090914-Understanding- AngularJS-Factory,-Service-and-Provider.html
  • 13. What is AngularJS? Ans: AngularJS is a javascript framework used for creating single web page applications. It simplifies binding javascript objects with HTML ui elements. It allows you to use html as your template language and enables you to extend HTML’s syntax to express your application’s components clearly. What are key the features of Angularjs? Ans: Model, View, Controller, Directives, Filters, Scope, Services, Data Binding. What is a directive in AngularJS and what are different types of directives? Ans: Directives are attributes decorated on the HTML elements. All directives start with the word “ng”. As the name says directive it directs angular what to do. During compilation process when special HTML constructs are encountered a function is triggered, this function is referred as directive. It is executed when the compiler encounters it in the DOM. 1) Element Directive 2) Attribute Directive 3) CSS class Directive 4) Comment Directive What are the advantages of angularjs? Ans: 1) AngularJS supports MVC pattern. 2) Using angularjs can do 2 ways binding. 3) It has pre-defined form validations. 4) It supports client-server communications. 5) It supports animations. What is “$rootScope” and how is it related with “$scope”? Ans: “$rootScope” is a parent object of all “$scope” angular objects created in a webpage. How is the data binding in angularjs? Ans: its two way binding. So whenever you make changes in one entity the other entity also gets updated.