Showing posts with label js. Show all posts
Showing posts with label js. Show all posts

Wednesday, 11 February 2015

Introduction

What is AngularJS?

•AngularJS extends HTML with new attributes.
•AngularJS is perfect for Single Page Applications (SPAs).
•AngularJS is a JavaScript framework. It can be added to
an HTML page with a <script> tag.
•AngularJS extends HTML attributes with Directives, and
binds data to HTML with Expressions.

How to start?
•For running angularjs application you have to install
“angular.min.js” file from 
And put that file into <script> tag and its destination give 
to the ‘src’ attribute. 

Directives
AngularJS directives are HTML attributes with an ng prefix.
The ng-init directive initialize AngularJS application
variables.
use data-ng-, instead of ng-
Expressions are written inside double braces: 
E.g. {{expression}}.
List of directives
ng-app - Root element of application. It automatically
   initialize the application when a web page is loaded.
ng-model - Name of value to input field.
ng-bind - Binds the innerHTML of the <p> element to the
   application variable name.
ng-init- Initial values for application.
ng-controller-  Control the application.
ng-repeat - Repeats an HTML elements.
ng-disabled- bind data to disable attribute of HTML.
ng-show - show or hide an HTML elements.
ng-hide - hide or show an HTML elements
ng-click - define click event

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 lower case.
orderBy                   Orders an array by an expression.
uppercase               Format a string to upper case


filter can be added to a directive with a pipe character (|) and
a filter.

e.g.  <li ng-repeat="x in names | orderBy:'country'">

AngularJS XMLHttpRequest

   AngularJS $http is a core service for reading data from web
server  $http.get(url) is the function to use for reading
server data.

Cross-Site HTTP Requests
 Requests for data from a different server, are called cross
site HTTP requests.


AngularJS Module
 Modules define applications. All application controllers
should belong to a module.

Without module
With Module

We can make form using angularJS.

AngularJS forms and controls can validate input data.

AngularJS forms and controls can provide validation
services, and notify users of invalid input.

HTML form attribute novalidate is used to disable default
browser validation.


Application:

Go to the link and run the code:

http://jsfiddle.net/eheupo0v/1/